Hussein
Hussein

Reputation: 13

Data import SQL Server 2008

I'm adding data into a table in my database from a VB application. But, I need to know, is it possible that some of the data I added can be imported to another table?

example:

table1(ID,FisrtName,LastName) data are added completely  
table 2 specific (FirstName, LastName)  

Upvotes: 1

Views: 130

Answers (2)

Redi
Redi

Reputation: 183

Use a Trigger AFTER INSERT on the table 1 and the thing is done automatically after inserting the data on table 1 or if the data has already been inserted then use a select insert statement like.

INSERT INTO dbo.Table2(FirstName,LastName) SELECT T.FirstName,T.LastName FROM dbo.Table1 AS T

And that should be it.

Upvotes: 1

Mikecito
Mikecito

Reputation: 2063

insert into table2 (FirstName,LastName) select FirstName,LastName from table1;

Upvotes: 2

Related Questions