Posts

Showing posts with the label SQL SERVER

SQL Query to Insert records in Table from one SQL Server instance to another

Before proceeding with the insert logic make sure following points: 1. Make sure that the target SQL Server is added in sys.servers through SQL Query :           select * from sys.servers 2. if the target SQL Server is not in sys.servers you can add it by using sp_addlinkedserver stored procedure, Such as sp_addlinkedserver '<SEREVR NAME>' Execute the following SQL Query:  INSERT INTO dbo.[TableName]    SELECT *    FROM [ServerNAme].[DataBaseName].dbo.[TableName] SIMILAR SCENARIO CAN BE USED FOR UPDATE AS BELOW: update dbo.SalesTable  set custAccount = ST2.CustAccount  from dbo.SalesTable ST1  inner join [ServerNAme].[DataBaseName].dbo.SalesTable ST2  on ST1.SalesID= ST2.SalesId