Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Empty duplicate table

Status
Not open for further replies.

joepeacock

Programmer
Nov 5, 2001
74
US
Hello,

I am trying to duplicate a project and I need some help here. What I am trying to do is duplicate Table A, which has 50 or so columns and 30,000 or so records. I need table B to have identical columns, with all of the same datatypes, default values, indexes, increment seeds, etc. as Table A, but start with 0 records. I can't just duplicate the entire table, then delete the records, because I need the next ID to start at 1, not at 30,001. Please let me know how to go about this.

Joe
 
Do you have SQL Enterprise Manager (EM) and Query Analyzer (QA)? If so the follwoing wil work.

Open the database in EM. Right click the table. Select All Tasks | Generate SQL Script. Click on the Options tab. Select all the options under Table Scripting Options. Click on OK to generate the script o a file or click the Geneal tab and the Preview button.

If you generate to a file, load the file into QA. If you chose Preview, copy the preview to the clipboard and paste in a QA window. Change the table name. Run the query to create the table. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Thanks for the suggestion. What I wound up doing was setting up a DTS packet with a Transfer Object and just told it to copy the tables I needed with all of the structure in place, but no data. So simple...

Joe
 
Create a task with a "Copy SQL Server Object Task", select the source database, destination database(a different one), the table to copy (uncheck "copy all objects"), uncheck "Copy Data", uncheck "Use default options" and click "Options" to select what you want to copy (users, roles, indexes, triggers, keys, ...)
 
Yeah... that's what I did... it worked...

Sorry, maybe I wasn't clear.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top