Skip to content

Instantly share code, notes, and snippets.

@SafeerH
Created August 28, 2017 07:59
Show Gist options
  • Save SafeerH/e536d8f7a63cf01d7bfa497b0eae790d to your computer and use it in GitHub Desktop.
Save SafeerH/e536d8f7a63cf01d7bfa497b0eae790d to your computer and use it in GitHub Desktop.
Copy table data between databases
SET IDENTITY_INSERT [mydb_to].dbo.[A] ON
INSERT INTO [mydb_to].dbo.[A]( col1, col2, col3, ..., coln ) --List the names of columns
SELECT * FROM [mydb_from].dbo.[A] WHERE reqid = 201
SET IDENTITY_INSERT [mydb_to].dbo.[A] OFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment