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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 sp to copy from one table to another

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2004-12-01 : 14:19:02
Is there a way to easily copy all fields (except identity) from one table to another in a stored procedure and then delete the row from the first table after it's inserted in the second.

Basically I have data in a temp table.
After I do all validation I will want to move it to the regular table (same structure) and delete from temp.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-12-01 : 14:29:41
INSERT INTO Table1...
SELECT...
FROM #Temp
WHERE...

DELETE FROM #Temp WHERE..

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-12-01 : 14:58:29
They're looking for

INSERT INTO myTable99(All Cloumns Except Col1)
SELECT All Columns Except Col1

Doesn't exists

BUT You could SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = 'myTable99'

So you don't have to type them all out



Brett

8-)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-12-01 : 15:00:16
Ah, lazy programming.

Tara
Go to Top of Page
   

- Advertisement -