January 27, 2005 at 7:55 am
hiya,
I want to copy all the rows:
1) FROM table A
2) TO table B
thereby, completely overwriting the rows in table B.
I am using a SELECT INTO statement, but it seems to want to RE-CREATE the table.I would like to be able to select into an EXISTING table.
<sql>
SELECT *
INTO tblA
FROM tblB
</sql>
Can anyone tell me the simplest way to do this? I don't think I have to use a UDF or anything.
cheers,
yogi
January 27, 2005 at 8:03 am
can't you just drop the table B?? and then execute the select .. into
January 27, 2005 at 8:18 am
You can do something like this :
TRUNCATE TABLE TableB
Insert into TableB (Col1, Col2, Col3...) (Select Col1, Col2, Col3 from TableA)
January 27, 2005 at 8:32 am
hiya,
well, they both work.Thanks.
yogi
January 27, 2005 at 8:34 am
Yes they both work both my version will not cause the sp to recompile. This can be a great time saver if the proc is not performing well... and it's considered best pratice to create the table only once whenever possible.
January 28, 2005 at 3:23 am
salut Remi,
thanks for the extra tip
a plus,
yogi
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply