Tavousi
Tavousi

Reputation: 15456

Use select into statement in sql

I use SQL Server 2008. I have a database (Database1) that has one table (Table1) and I want copy the data of this table to another table (Table2) that it is in another database (Database2). How to I can write the "SELECT INTO" statement. It is noteworthy that Table2 is exist in database2 and it has saveral keys and index. Thanks alot.

Upvotes: 3

Views: 136

Answers (1)

Alex K.
Alex K.

Reputation: 175826

You can simply;

insert into database2.dbo.table2 (f1, f2, fN)
  select f1, f2, fN 
  from database1.dbo.table1
  where x = y

Upvotes: 3

Related Questions