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
 General SQL Server Forums
 New to SQL Server Programming
 generating create statement

Author  Topic 

ashuadi
Starting Member

5 Posts

Posted - 2007-06-10 : 17:21:36
Hi,
I am new to SQL Server and need your help.
I have a table (old_table) with about 500 columns and each column of type varchar. I have to generate a table (new_table) which has all the columns of the old table but with different data types.

Is there a way I can use the syscolumns to generate a “create table” statement?

Thanks.

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-06-10 : 19:03:54
You can generate script of the old table then modify the script.
Go to Top of Page

ashuadi
Starting Member

5 Posts

Posted - 2007-06-10 : 19:12:23
Actually I had a .dat file which i imported into sql server as old_table.
i can write the create table statement with 500 columns but i thought there would be a better way to do this using syscolumns.
any help would be appreciated.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-10 : 22:53:22
You can use Enterprise Manager (2000) or SQL Server Management Studio (2005) right click on the table to generate the script.



KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-11 : 08:23:57
Generate SQL script is best option
You can try this as well
http://sqlteam.com/forums/topic.asp?TOPIC_ID=53007

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -