SQL SERVER copy a table
#1
Scooby Regular
Thread Starter
Join Date: Jan 2002
Location: Plymouth
Posts: 960
Likes: 0
Received 0 Likes
on
0 Posts
OK DB bods,
I have a table that needs copying into a specific named table regularly.
I have tried using 'select * from t1 into t2' but that does not work if t2 already exists and the user that is running the job doesnt have permission to drop the table.
is there a similarly quick way of copying the contents of one table into another? (apart from a cursor on each line which is very slow)
also is there a way to get certain parts of a stored procedure to run under different permissions, for example to run certain parts of a procedure as SA, to overcome the above.
cheers
I have a table that needs copying into a specific named table regularly.
I have tried using 'select * from t1 into t2' but that does not work if t2 already exists and the user that is running the job doesnt have permission to drop the table.
is there a similarly quick way of copying the contents of one table into another? (apart from a cursor on each line which is very slow)
also is there a way to get certain parts of a stored procedure to run under different permissions, for example to run certain parts of a procedure as SA, to overcome the above.
cheers
#2
Scooby Regular
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes
on
0 Posts
Eagle,
Rather than drop and re-create t2 could you not just issue a:
DELETE FROM <t2>
INSERT INTO <t2> (columns) SELECT (columns) from t1
periodically or setup and INSERT trigger on t1 to automatically post records to t2???
Gary
Rather than drop and re-create t2 could you not just issue a:
DELETE FROM <t2>
INSERT INTO <t2> (columns) SELECT (columns) from t1
periodically or setup and INSERT trigger on t1 to automatically post records to t2???
Gary
Thread
Thread Starter
Forum
Replies
Last Post
JonMc
Subaru Parts
22
06 February 2016 09:50 PM
ossett2k2
Engine Management and ECU Remapping
15
23 September 2015 09:11 AM
pimmo2000
Computer & Technology Related
2
21 September 2015 12:04 PM