Monday, May 17, 2010

tsql INSERT INTO for bulk copy of records from SqlServer table to table

I have been using tsql

Select * into Tbl2 from Tbl1 where FName = 'David'

for a long time, as a shortcut to create new table Tbl2, a copy of Tbl1 including schema and data.

I'm glad I finally found out about :

Insert into Tbl2 ( LastName , FirstName , AdmitDate) select Last, First, RevDate from Tbl1 where FName = 'David'

to use when Tbl2 is already in existence.

No comments:

Post a Comment