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)
 copy the table with content and same permsion

Author  Topic 

yan19454
Starting Member

3 Posts

Posted - 2006-05-22 : 13:54:43
I used

this
exec sp_dboption Annual_Edu_Test, 'select into/bulkcopy', true


CREATE TABLE [Quiz Name List Win FY07] SELECT * FROM [Quiz Name List Win FY06]


Incorrect syntax near the keyword 'SELECT'.

why ?

This method did not great the same permission as old table , too.

How can I do that ?

Thanks.

Kristen
Test

22859 Posts

Posted - 2006-05-22 : 13:58:11
SELECT *
INTO [Quiz Name List Win FY07]
FROM [Quiz Name List Win FY06]

will copy the data across to a new table, but I think you will have to apply the permissions manually

Kristen
Go to Top of Page

jsiedliski
Yak Posting Veteran

61 Posts

Posted - 2006-05-22 : 18:04:38
If your ultimate goal is to create a copy of the table with data and permissions, I would suggest;


1. Script the CREATE TABLE code (including keys, permissions, etc) - you can do that in Enterprise Manager - right click on the table and select "all tasks \ generate sql script"

2. Create your new table (change all names (espectially the table name) in the script from step 1 - MAKE SURE you change the names or the DROP OBJECT part of the script will delete your original table)

3. Copy data from old table to new table (INSERT INTO.... or using DTS, etc.))

This will take loner than using SELECT INTO, but you will be assured that both tables have the same structure (including indexes, constraings, etc.)

Hope that helps,

Jack

:)
Go to Top of Page
   

- Advertisement -