How to insert into the PK column when it is an auto-number

Normally, trying to insert data into an identity column (autoincremental column) results in an error message. However, there are cases when we need to do this, and using SET IDENTITY_INERT, it is possible. Here is how: SET IDENTITY_INSERT MyTable ON INSERT INTO MyTable(MyTableId, …) VALUES (42, …) SET IDENTITY_INSERT MyTable OFF Here is the message […]

READ MORE

How to keep track of database structure changes

Here is an interesting method for keeping track of modifications brought to an SQL Server database structure: http://www.codeproject.com/KB/database/sql2005dba.aspx This is quite useful when working on a new version of a database driven web site, since all modifications made to the development database will eventually have to be applied to the QA database and finally the […]

READ MORE