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 2000 Forums
 Transact-SQL (2000)
 Getting the Create Table sql script

Author  Topic 

kiwy
Starting Member

6 Posts

Posted - 2005-10-01 : 20:09:44
I'm looking for a way of getting the create table sql script.
In mysql i use to do it with "SHOW CREATE TABLE table_name", but i cannot find any equivalent in mssql.
Is there a SP that dose this?

i'm new to mssql, so dont be very hursh with me
thanks

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-10-01 : 20:15:37
What edition of SQL Server (MSDE, Enterprise, etc)?

Take a look at this:

http://www.mindsdoor.net/DMO/DMOScriptAllDatabases.html

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-10-02 : 08:48:04
Hi
What i understood is that you want the script for creating table in SQL Server.

There are 2 ways of doing that,
1 Using Query Analyser

in the Query Analyser in the toolbar there is option of object browser or you can press f8 there u can see all the database which are attached to the particular server... then go to the database where u want to script the tables.. Right click on the table then you will get the option of Script object.. there are 3-4 options over there you can check them.. how you want the script to be viewed..

The 2nd option is using the enterprise manager
Go to the databse and then right click on the table .. click on All Tasks and then click on the Generate Script and you can view the scripts.. for creating ..the tables..

I hope this helps you..

All the best ..

Complicated things can be done by simple thinking
Go to Top of Page

kiwy
Starting Member

6 Posts

Posted - 2005-10-02 : 09:07:00
The problem is that i want to be able to this from my app. and not from a visual tool.
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-10-02 : 09:27:53
That's why I pointed you in the direction I did. Did you look at it?

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

kiwy
Starting Member

6 Posts

Posted - 2005-10-02 : 11:07:41
quote:
Originally posted by derrickleggett

That's why I pointed you in the direction I did. Did you look at it?

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.



yes. and i need a litle help with redirecting the output of s_ScriptObjects SP not to a file, but as returning values.
because i'll execute the sp over the network via ado.

i think this is the part where i should make the changes, but i need some help

----
exec @rc = sp_OAMethod @objServer, @sql , @buffer OUTPUT, @ScriptType , @tmpFileName
select @sql = 'type ' + @tmpFileName + ' >> ' + @FileName
exec master..xp_cmdshell @sql
----
Go to Top of Page

viljun
Starting Member

1 Post

Posted - 2010-01-08 : 15:29:43
quote:
Originally posted by kiwy

I'm looking for a way of getting the create table sql script.
In mysql i use to do it with "SHOW CREATE TABLE table_name", but i cannot find any equivalent in mssql.
Is there a SP that dose this?

i'm new to mssql, so dont be very hursh with me
thanks




I just wrote this for you (in asp). There's also show create database -function:

[url]http://www.varuste.net/show_create_table.html[/url]

Ville
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-01-08 : 15:44:49
Wow. That's what I call thread necromancy
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-11 : 02:15:25
quote:
Originally posted by russell

Wow. That's what I call thread necromancy


Now-a-days most of the first time posters start answering to the very old question first

Madhivanan

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

- Advertisement -