First setup a link server to the other database.

SET IDENTITY_INSERT tbDestination ON

INSERT INTO tbDestination
(
 	[Id]
      , [Col01]
      , [Col02]
)
SELECT 
 	[Id]
      , [Col01]
      , [Col02]
FROM [LinkServerName].[DatabaseName].[dbo].[tbTableSource]

SET IDENTITY_INSERT tbDestination OFF

SELECT COUNT(*) FROM [LinkServerName].[DatabaseName].[dbo].[tbTableSource]
SELECT COUNT(*) FROM tbDestination
Last modified: April 23, 2019

Author

Comments

Write a Reply or Comment