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
 Saving Scripts

Author  Topic 

gregoryagu
Yak Posting Veteran

80 Posts

Posted - 2011-04-17 : 19:01:41
What is the best way to save scripts so you can easily find them later?

From MSSMS, I know you can do a "Save As" and put it on your hard drive somewhere, but this seems to disconnect it from the database so if you end up on a different computer, but need it for a particular database, you are out of luck.

Seems like creating a Stored Procedure out of it is the only other option. But at least it keeps it in the database.

Greg

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-17 : 21:28:33
You should integrate SSMS with a source control. It'll still be disconnected from the database, however saving things in a stored procedure isn't the purpose or stored procedures.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

gregoryagu
Yak Posting Veteran

80 Posts

Posted - 2011-04-18 : 09:12:07
Yes, good point. Another thought I had is what about creating a table, and in that table keep the scripts. The it would be easy to keep the time, date, reason for the script, notes etc as well as the script that applies to a particular database. Just a thought!
Go to Top of Page

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2011-04-18 : 09:19:55
At my previous employer, we had under every software projects a folder called "Update Scripts". In that folder is where we put our .sql files. Our files were named using a convention that kept them in order. If I created a table today my script would be saved as "110418_001 tblTableName CREATE.sql". The 110418 part of the script is the date, two digit year, then month then day. The _001 part is the script number for the day. We had a small team that all worked together in the same room so we would call out "taking number 1" and the next person would take 2 and so on and so forth. That worked for us since we were together, but on a larger team that is spread out, that might not work.

We had a process for updating the database with our scripts that involved a piece of internal software that ran all of our scripts and then stored information about the script in a database. That software ensured that scripts weren't ran more than once.

Hope this helps.

Hey, it compiles.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-18 : 13:11:56
Keeping the scripts in a table would not be easy. Just getting them in there and out isn't a small task. Just have proper source control in place and organize things right in thee.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

gregoryagu
Yak Posting Veteran

80 Posts

Posted - 2011-04-18 : 13:59:56
OK, good points.
Go to Top of Page
   

- Advertisement -