Identity Column – Moving data

In MS SQL Server, I was copying data from one database to another and wanted to preserve the values in the identity column. I had to put these statements around my sql.

SET IDENTITY_INSERT tablename ON
go

go

SET IDENTITY_INSERT tablename OFF
go

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s