Sample Code for SQL Distributed Query and insertion of incremental columns. For more information, see.
Sample Code for SQL Distributed Query and insertion of incremental columns. For more information, see.
The Code is as follows:
Truncate table TestTable
EXEC sp_configure 'show advanced options', 1; -- enable advanced configuration
RECONFIGURE
EXEC sp_configure 'ad Hoc Distributed Queries ', 1; -- enable Distributed Query
RECONFIGURE
Set IDENTITY_insert TestTable on -- sets the maximum number of insert increments for a table.
Insert into TestTable (ID, Date, Info) SELECT a. ID, a. Date, a. Info
From openrowset ('sqloledb', 'V'; 'sa '; '123 ',
'Select * FROM TestDatabase. dbo. testtable') AS
Set IDENTITY_insert TestTable OFF -- sets the number of insert increments not allowed for a certain table
EXEC sp_configure 'ad Hoc Distributed Queries ', 0; -- disable Distributed Query
RECONFIGURE
EXEC sp_configure 'show advanced options', 0; -- disable advanced Configuration
RECONFIGURE