|
Thread: Sql
-
Nov 19th, 2002, 07:59 AM
#1
Thread Starter
Junior Member
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
-
Nov 19th, 2002, 08:54 AM
#2
Hyperactive Member
hi,
Insert into Live_Table Select * from Temp_table
assuming that both the tables have the same structure.
regds,
ashay
"If you should die before me, ask if you could bring a friend."
- Stone Temple Pilots
-
Nov 19th, 2002, 11:54 AM
#3
Frenzied Member
Do you need to do this programatically? Because DTS is the way to accomplish this..
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Nov 19th, 2002, 12:45 PM
#4
Frenzied Member
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.
-
Nov 19th, 2002, 02:29 PM
#5
Frenzied Member
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)
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Nov 20th, 2002, 12:47 AM
#6
Hyperactive Member
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"
regds,
ashay
"If you should die before me, ask if you could bring a friend."
- Stone Temple Pilots
-
Nov 20th, 2002, 03:28 AM
#7
Addicted Member
Helpful
Insert into Live_Table(field1,field2,field3) Select field1,field2,field3 from Temp_table. Hope it is helpful for u
-
Nov 20th, 2002, 08:00 AM
#8
New Member
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
-
Nov 20th, 2002, 10:11 AM
#9
Frenzied Member
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..
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|