How and where do you store your written T-SQL code?

  • Hi everyone,

    Most DBAs will write some T-SQL code, I have lots from over the years. But were to keep this code so that you can find it again if/when you are looking for it?

    I used to keep my code as individual .sql files but that makes it harder to search or remember what that code did without opening it. Now I have an excel spread sheet but that's getting long and boring. Guess you could create a database to store the code but is there anything else?

    So my question to you is how/where do you store your code? If you use a tool, is it free?

    Just a thought.

    Rudy 🙂

    Rudy

  • For the last year or so - I've been using Database projects in Visual Studio to store my code. The projects then get stored in Visual Source Safe for Version Control.

    It allows me to organize them using the projects, AND I can always run searches to find what I need.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Thanks for your reply Matt. Neat we to store and search

    Rudy 🙂

    Rudy

  • I keep them in directories on a file share.

    I just looked and had a little more than 2,100 .sql files.

  • Another vote for Visual Studio. Hook it into source control and then you get versions of your scripts too. Very handy when one of them suddenly breaks for no apparent reason.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Create a suitably named folder in your source control system

    (Visual SourceSafe, Perforce, StarTeam, etc.)

    You get:

    1. Storage where others (your other DBAs) can access them

    2. Backup of what you have developed

    3. version control for enhancements and bug fixes (yeah, us DBAs are not perfect)


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply