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?
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
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.