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
Comments