views:

72

answers:

2

I have a database I have inherited, and my best practice is to create the scripts to create the objects (tables, stored procedures and views) and then version control these.

It would like to have all the objects in this database scripted out, and put into source control; but on SQL Server 2005 (SQL Server Management Studio) it appears - at least to me - that the option to create one file per object that was available on Enterprise Manager has not made it through to SQL Server Management Studio.

Am I just not seeing the wood for the trees, or has the option that was there in Enterprise Manager not made it through ?

Does anyone have an effective way to create one script file, named as per the object ready for adding to source / version control ?

+2  A: 

In SQL Server 2005 SP2, this is supported. If you select the option, it will give you files named after the objects, but also including the type of the object in the file name.

http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124774

EDIT

Added link confirming that the change was in SP2.

Dave Cluderay
+1  A: 

Here is a link to a CodeProject vbscript that you can use to scripting all the objects of an SQL database on separate files. I have downloaded, modified slightly for my naming purpouses and it works great.

http://www.codeproject.com/KB/vbscript/0g_SqlExtract.aspx

tekBlues