Blog Home  Home Feed your aggregator (RSS 2.0)  
Venexus DotNetNuke Blog - Reset Identity, Inserting Into Identity, and differences between Scope_Identity and @@Identity
DotNetNuke Articles, Code Snippets, Errors, and News
 
 Monday, May 15, 2006

I always forget the syntax for resetting identity columns. For example, recently on a development DNN installation, we needed to reset all identity columns back to 0 after data testing was complete. So, as a reminder to myself, here's the SQL:

DBCC CHECKIDENT (TableName, RESEED, 0)

If for some reason you need to temporarily allow inserts into the Identity column, then you can use the following:

Set Identity_Insert TableName On

Once you have executed your statements, you can turn it back off:

Set Identity_Insert TableName Off

And for the differences of Scope_Identity and @@Identity: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sa-ses_6n8p.asp

Monday, May 15, 2006 9:51:36 AM (US Eastern Standard Time, UTC-05:00)  #       | 
Copyright © 2010 Venexus, Inc.. All rights reserved.