Wednesday, May 26, 2010

Reset table identity column

DBCC CHECKIDENT(Product,RESEED,0)
Where Product is my table name

Difference between TRUNCATE & DELETE

About TRUNCATE
--------------
Much faster than Delete.
Can't be rollback.
Can't use where clause with it.
Can't use on a linked table. (When use on a table which is linked to another table you will see this message "Cannot truncate table 'TableName' because it is being referenced by a FOREIGN KEY constraint."

After using TRUNCATE all of the memory space is released back to the server.


About Delete
--------------
Slower than TRUNCATE.
Can be rollback (as its a DML operation).
Can use where clause with it.

After using Delete Command The memory will be occupied till the user does not give ROLLBACK or COMMIT.