Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select into

Author  Topic 

kifeda
Posting Yak Master

136 Posts

Posted - 2007-05-05 : 00:05:01
Hi All,

I have two table and I'm trying to select information from table 1 (testtable) into table 2 (tbldsmCodes). Here what I have so far:

SELECT *
INTO tbldsmCodes
FROM testtable
WHERE (ID BETWEEN 332 AND 366)

this would work, except there table tbldsmcode already exist. I want to copy the data from testtable to tbldsmCodes. The problem is that when I excute the sql statement I get an error that says the table already exist. It wants to create a the table tbldsmCodes but the table already exist. How do I copy into a table that already exist?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-05 : 00:06:53
use

INSERT INTO tbldsmCodes( cola, colb, colc, . . . )
select col1, col2, col3
from testtable
. . .



KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-05 : 03:04:23
Provided column datatypes are identical

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -