0

I want to move data from server db table to local db table but need to make sure that the Ids of records won't change while copying from main Server db table. like enter image description here

The issue I am having is when I move this to local, it merges the next to last record of the table and starts incrementing from number 20. I want the Ids to remain concurrent or the same in both Local and Production Db. Any possible Solutions?

0
0

You can use SET IDENTITY_INSERT my_table ON before performing the insertion of the data in you local table and on finish use SET IDENTITY_INSERT my_table OFF and your column will take the following value.

Example:

SET IDENTITY_INSERT [dbo].[table] ON

GO

INSERT INTO [dbo].[table] ([CustomerID] ,[FirstName]) VALUES (1 ,'qqq');

INSERT INTO [dbo].[table] ([CustomerID] ,[FirstName]) VALUES (2 ,'eee');

SET IDENTITY_INSERT [dbo].[table] OFF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.