June 16, 2006 at 9:10 am
Is there an easy way to create a 'create table statement' from a preexisting table in SQL Server 2000?
June 16, 2006 at 9:33 am
well, in enterprise manager, you can right click on the table, all tasks, Generate sql script.
In the options tabl select Foreign keys, Indexes and triggers, hit preview, or Go.
Or in Query analyzer, open the object browser, right click it, and select new window, Create.
June 16, 2006 at 9:54 am
It's not terribly well written, but here's an article which explains how to do this programatically. The title should be 'Creating a "CREATE TABLE" script from a stored procedure", but it got edited during publishing.
http://www.sqlservercentral.com/columnists/rrandall/creatingascriptfromastoredprocedure.asp
The upshot is that you have an SP which looks like this...
exec dbo.get_create_table_script @object_text output, 'my_server', 'my_database', 'my_table'
Ray's suggestion might be sufficient for what you need, but I thought I'd mention this method in case it might be useful.
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
June 16, 2006 at 8:18 pm
If all you want to do is copy the structure from one table to another, without any need for indexes, triggers, permissions, etc., then the easiest method is probably:
SELECT * INTO newstructureTableName FROM preexistingTableName WHERE 1=2
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply