Is there a simple process in SQL 2005 for spitting all of my stored procedures out to individual .sql files. I'd like to move them into VSS, but am not too excited by the prospect of clicking on each one to get the source, dumping it into a text file and so on..
+2
A:
You can run this select:
select
O.name, M.definition
from
sys.objects as O
left join
sys.sql_modules as M
on O.object_id = M.object_id
where
type = 'P'
and you get the name and source code for stored procedures. Propably most easy way, how to put it in files is in some "classic" languge like c#, java, etc ...
TcKs
2008-12-03 15:56:10
Nice! Didn't know about that one.
VVS
2008-12-03 17:59:02
+9
A:
In SQL Management Studio right click on the database, go to tasks -> Generate Scripts, walkthrough the wizard. One of the pages will let you script each object to its own file.
JoshBerke
2008-12-03 15:57:41
+3
A:
If you want to version your entire database, Microsoft has a SQL Server Database Publishing Wizard (you can download it here). The overview says there's direct integration with Visual Studio, but I haven't used it personally to vouch for how good (or bad) it might be.
Scott A. Lawrence
2008-12-03 16:06:15