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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table question - newbie

Status
Not open for further replies.

scottRen

Technical User
Feb 4, 2005
69
0
0
CA
hi i have a table called users that is set up with column names and has data in it.

I would like to create another table called people which needs to have identical column names, i don't care about the data. How can i easily accomplish this?


thanks
 
Open enterprise Manager, drill down to the database then the table and then Right mouse click on the table. Then choose All Tasks.. Generate SQL Script. Script out the table.

Then Open Query Analyzer. Choose File..Open from the menu and find your script. Once the script is in, Change the table name and execute the script

Thanks

J. Kusch
 
If you're using SQL Server 2000, Query Analyser has a very useful feature for this:
From the Tools menu, show the Object Browser. In the object Browser's treeview, open up your database to expose the User Tables. Then just right-click on the object of interest, and you get the option to script it as CREATE (and also options to script it as UPDATE, INSERT, etc). Then all you need to do is change the Table name and run the script, as with JayKusch's answer above.

It's been very helpful to me and saved me from having to type too much on many an occasion!
HTH
 
A shortcut way of doing this is :
select * into [people] from [users] where 1=2

--Kishore
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top