Script for create & drop database

Posted by Nishithraj under Sql Server on 1/26/2010 | Views : 2841 | Status : [Member] | Replies : 1
How do we create the scripts of a database(create database , Drop to as in SSMS) using a query? Sp_helptext works for stored procs but not for database.

I need to create sql file after generating the scripts..

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan


Posted by: Rtpharry on: 1/26/2010 [Member] [MVP] Bronze

You can create these scripts within SSMS by right clicking on a database and choosing Tasks | Generate Scripts.

Most windows in the SSMS have a toolbar along the top that lets you script out the current window. This turns whatever dialog settings you have configured into a sql script.

Unfortunately the Generate Scripts window doesn't have this feature.

I did find some discussion of third party tools in this thread:

There is something called SMO which lets you access the technology behind the Generate Scripts window. I think this would be your best bet:

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response