Question

I am about 10 months in to my DBA role and I am already accumulating quite the collection of scripts. Does anyone have any best practices or recommendations on how to store all of these scripts? I manage about 70 instances of SQL server and am looking for a way to have quick access to all of these scripts as I need them throughout the day and right now they are just piling up in a file system folder.

Is this the best way? Are there 3rd party tools that help organize them? Anyone have an amazing solution/recommendation?

Thanks ahead of time!

Was it helpful?

Solution

Get them into source control, pronto. They are your code, your source of truth about how the environments should be configured and operate. They are as important as the application and schema and deserve the same level of care and attention.

Once there you can version and branch them as required. Having 20 copies with no indication which is for what purpose will be a thing of the past.

Within the root folder I'd split them by purpose. For me this means a sub-folder for migration scripts, one for analysis, one for maintenance etc. Use what makes sense for your environment and for your way of thinking.

OTHER TIPS

I bet there is one within ssms object explorer settings generally where you see pre loaded sql scripts like backups, create logins etc... are stored. Also the best one I've been using and very famous or the one I personally like is GitHub. You may find various others like Bitbucket etc available online.

Moreover in my early days I used to have a DBA database of my own where I will keep data related to scripts that I use on my daily troubleshooting or check activities

Also I don't know how useful it is but u may find redgate swl script manager Useful

I have used a combination of GIT as well as naming files in a way that I can search for easily within vs code or similar.

I will store file names as an example as the following.

[Sales][Department].sql

[Sales][Staff].sql

[Profit][Staff].sql

I will then be able to search for key works. If i make a variation of the script for a difference cut/flavour of data I will create a new file just with that cut in and name accordingly. so if we are ever asked for the same thing again or something similar we have documented this and able to quickly re-produce.

This seems to have scaled well with my queries and other people within my team are now adoption this method.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top