Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

SQL SERVER copy a table

Thread Tools
 
Search this Thread
 
Old Mar 21, 2003 | 11:31 AM
  #1  
Eagle7's Avatar
Eagle7
Thread Starter
Scooby Regular
 
Joined: Jan 2002
Posts: 960
Likes: 0
From: Plymouth
Post

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
Reply
Old Mar 21, 2003 | 11:35 AM
  #2  
GaryK's Avatar
GaryK
Scooby Regular
 
Joined: Sep 1999
Posts: 4,037
Likes: 0
From: Bedfordshire
Post

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
Reply
Old Mar 21, 2003 | 11:39 AM
  #3  
Eagle7's Avatar
Eagle7
Thread Starter
Scooby Regular
 
Joined: Jan 2002
Posts: 960
Likes: 0
From: Plymouth
Post

cheers

ive managed to sort this now i think.

my permissions were all messed up.

cheers for help

[Edited by Eagle7 - 3/21/2003 11:41:02 AM]
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
JonMc
Subaru Parts
22
Feb 6, 2016 09:50 PM
IAN WR1
ScoobyNet General
8
Sep 28, 2015 08:14 PM
Littleted
Computer & Technology Related
0
Sep 25, 2015 08:44 AM
ossett2k2
Engine Management and ECU Remapping
15
Sep 23, 2015 09:11 AM
pimmo2000
Computer & Technology Related
2
Sep 21, 2015 12:04 PM




All times are GMT +1. The time now is 02:01 PM.