How to Reset autoincrement in Microsoft SQL Server 2008 R2

To reset autoincrement of table in microsoft SQL Server 2008, you canĀ use the DBCC CHECKIDENT command:

 DBCC CHECKIDENT ("YourTableNameHere", RESEED, 1);

But use with CAUTION! – this will just reset the IDENTITY to 1 – so your next inserts will get values 1, then 2, and then 3 –> and you’ll have a clash with your pre-existing value of 3 here!

IDENTITY just dishes out numbers in consecutive order – it does NOT in any way make sure there are no conflicts! If you already have values – do not reseed back to a lower value!

Differentiation of Table Variable and Temporary Table

A few days ago, I wrote the article about table variable and temporary table. Honestly, I didn’t knew why table variable was faster than temporary table.

it was just based on my experience when I made store procedure. And now, I’ll try answer the reason about that cases

Difference between Table Variable and temporary table Continue reading