-
Sql
Hello,
I dont know if this is the right forum for this question, but I'll give it a try.
I have created a table in SQL Server - lets call it TempTable in the Temp Database.
I now want to copy all the data from TempTable to LiveTable (both in the Temp db) using
a stored proc - ie T-sql. How do I do this? I want to COPY the data, NOT read (select) thru
each record in Temp and Insert into Live!!
I know there is some command to do this, but forgot what it is.
Thx,
L
-
hi,
Insert into Live_Table Select * from Temp_table
assuming that both the tables have the same structure.
regds,
ashay
-
Do you need to do this programatically? Because DTS is the way to accomplish this..
-
If I'm rebember correctly there is a SELECT INTO statement in SQL Server that you could use to copy data from one table to another, if structure is the same.
-
I didn't catch that they were in the same database.. I thought you were saying they were in different ones.. yes..
An example from SQL 2000 Books Online:
Code:
SELECT Shippers.*, Link.Address, Link.City,
Link.Region, Link.PostalCode
INTO NewShippers
FROM Shippers
JOIN LinkServer.DB.dbo.Shippers AS Link
ON (Shippers.ShipperID = Link.ShipperID)
-
hi,
My solution also works.Infact i usally use the method in my above post to copy data from one table to another.
R there any specific advantages of using "Select Into" :confused:
regds,
ashay
-
Helpful
Insert into Live_Table(field1,field2,field3) Select field1,field2,field3 from Temp_table. Hope it is helpful for u
-
Actually i am not sure about the t-sql but u can use this code ... if you hvae created the table templive with the same structure then
you can use this
insert temlive select * from temp where 1>0 try this ...i will look for a procedure...
Bye
-
Using 'Select Into' removes the requirement that the table structures match. You can assemble the data into the structure you need to insert. Other than that there is no real advantage. If the structures are not the same, 'Select Into' is the way to go.. if they are, your way works fine..