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 Scripts for all the tables.

Author  Topic 

Vijaykumar_Patil
Posting Yak Master

121 Posts

Posted - 2007-09-07 : 08:37:24
Hi ,
Can anyone help to generate scripts for all the tables in the db using Transact SQL.

Thank you

Necessity is the mother of all inventions!

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-07 : 08:38:31
why dont you make use of Generate SQL Script feature from Enterprise Manager

Madhivanan

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

Vijaykumar_Patil
Posting Yak Master

121 Posts

Posted - 2007-09-07 : 08:40:41
I am using SQL2005..and will need to do one table at a time. Or I am missing something.

Necessity is the mother of all inventions!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-09-07 : 08:42:08
use SSMS, select the required table, right click "Script Table as"


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Vijaykumar_Patil
Posting Yak Master

121 Posts

Posted - 2007-09-07 : 08:44:49
Khtan, thank you for that,that is what I dont want to do since there are 100s of tables in it.

Necessity is the mother of all inventions!
Go to Top of Page

Vijaykumar_Patil
Posting Yak Master

121 Posts

Posted - 2007-09-07 : 08:45:46
Isn't there a smarter way to do it??

Necessity is the mother of all inventions!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-09-07 : 08:48:24
quote:
Originally posted by Vijaykumar_Patil

Khtan, thank you for that,that is what I dont want to do since there are 100s of tables in it.

Necessity is the mother of all inventions!


you can select the required table(s) you want to script


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-07 : 08:51:13
You may need to change the code according to your need
http://www.nigelrivett.net/DMO/DMOScriptAllDatabases.html

Madhivanan

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

Vijaykumar_Patil
Posting Yak Master

121 Posts

Posted - 2007-09-07 : 08:51:42
Khtan, I still dont get what you meant by selecting the required tables. Ctrl + click doesnt allow multiply table selection. How do I achive that.

Necessity is the mother of all inventions!
Go to Top of Page

Vijaykumar_Patil
Posting Yak Master

121 Posts

Posted - 2007-09-07 : 09:10:46
Hey thank you Madhivanan..It works..but I have some problems . I get these two errors

Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', see "Surface Area Configuration" in SQL Server Books Online.
Msg 15281, Level 16, State 1, Procedure sp_OACreate, Line 1
SQL Server blocked access to procedure 'sys.sp_OACreate' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online.


Necessity is the mother of all inventions!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-09-07 : 09:16:59
quote:
Originally posted by Vijaykumar_Patil

Khtan, I still dont get what you meant by selecting the required tables. Ctrl + click doesnt allow multiply table selection. How do I achive that.

Necessity is the mother of all inventions!



Did you try CTRL-A, Ctrl-Left Click ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2007-09-07 : 09:24:54
Go to View\Object Explorer Details there you can multi-select your tables

Jim
Go to Top of Page

Vijaykumar_Patil
Posting Yak Master

121 Posts

Posted - 2007-09-07 : 09:38:37
Thank you guys , got it, I need to select the tables in the Summary Window doesnt work in the Object Explorer.

Necessity is the mother of all inventions!
Go to Top of Page
   

- Advertisement -