Insert data from one DB table to another DB table

Posted by Nmdjack under LINQ on 3/18/2014 | Points: 10 | Views : 778 | Status : [Member] | Replies : 1
Dear friends,

I have urgent issue in my application. Can you please help me for the following scenario.

I have two table with same schema, In different server. I Need to insert into table from one database to another database table based on user criteria.

Before insert i want to check record is already exists in the designation table or not.

If the records are exists don't want to insert the records. I need to insert only different records.




Responses

Posted by: A2H on: 3/19/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,
You can acheive your requirement using Insert Into statement in sql
Check the below link for more details
http://www.w3schools.com/sql/sql_insert.asp

Sample Code is given below
INSERT INTO [SourceDatabase].[dbo].[SourceTable](
Name, DateColumn
)
SELECT Name, DateColumn
FROM [TargetDatabase].[dbo].[TargetTable] ;


You need to change the column as per your table design


Thanks,
A2H
My Blog

Nmdjack, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response