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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to Get Table Definition

Author  Topic 

whitebird
Starting Member

12 Posts

Posted - 2008-03-06 : 08:17:37
Hi,
I need a query to get table Definition in sql server 2005.
please help me out.



Raghu sunkara.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-03-06 : 08:21:06
Make use of Generate Script option from Management Studio

Madhivanan

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

whitebird
Starting Member

12 Posts

Posted - 2008-03-06 : 08:23:04
Hi Madivanan,
Actually i need to get the table definition programatically. so , i need a query to get the table definition. please help me out

Regards,


Raghu sunkara.

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-06 : 08:24:36
sp_help <tablename>
Go to Top of Page

johnsql
Posting Yak Master

161 Posts

Posted - 2008-03-20 : 12:23:46
quote:
Originally posted by visakh16

sp_help <tablename>



I am afraid the command does not generate script for table defintion as "create table dbo.mytable (...)".
Is there an exact way to write such script to get table defintion script as I do using EnterPrise Manager?

I am looking for such a script. Thanks.
Go to Top of Page

PABluesMan
Starting Member

26 Posts

Posted - 2008-03-24 : 15:10:31
I would use the [sp_help] system proc and stash the results into a temp table; then write code to loop through the temp table and build the necessary script.

Or, you could use a scripting language such as VBScript and use the SQL-DMO object.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-02 : 02:48:13
quote:
Originally posted by whitebird

Hi Madivanan,
Actually i need to get the table definition programatically. so , i need a query to get the table definition. please help me out

Regards,


Raghu sunkara.




You may try
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=53007

Madhivanan

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

- Advertisement -