What do you use to store useful t-sql code?

  • I am interested in what people use to store useful t-sql code that they come across. I'm talking about little gems like using ALTER DATABASE to move ldf's and mdf's to different file locations, running sp_cycle_errorlog to recycle the SQL Log, determining orphaned users in a database, testing for null SQL passwords etc etc. The list is endless...

    Whilst I appreciate a lot of this information can be found in BOL, a lot of it is also found online within sites like this one. Rather than bookmark each useful page I come across it would be nice to have some sort of repository and I don't mean something like SubVersion (or similar) which seems like overkill for what I want.

    At the moment i'm using Excel but there must be something better out there for this.

    Any Ideas?

  • For different DDL Statements (CREATE, DROP), Template Explorer in SSMS is the best place to get the idea and then BOL.

    For scripts, it depends upon your needs. I personally have a folder containing all the queries that I know i cant remember for a long time.

    Not found any specific website for that. It might be due to fact that it depends on each individual's need....

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • I setup a SharePoint web site that I share out to the rest of the company. As I find useful scripts, I post them out to the site. I don't have to worry about losing them since their on a regular backup.

    For the scripts that I use most often, I put them in a scripts work folder

    For better, quicker answers, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Small scripts that I use all the time go into Red Gate SQL Prompt. Bigger scripts go out to a sharepoint site. All our projects are built from source control, so we have scripts in VSS or TFS, depending on the age of the project.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • i use the cliptext feature of Editplus to save all my snippets and valuable code; i try to organize with a keyword and brief description;

    if i double click on the line on the left, the full snippet, which might be hundreds of lines of code, appears in the document i'm editing.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks for all the responses. Lowell that's exactly what i'm after do you know of a free alternative to EditPlus?

    Cheers,

    Mark

  • I keep two folders on the micro-SD card in my phone, one for administrative scripts (things like backups and index maintenance), and one for clever stuff (like string parsing, Numbers table creation, a clever string concatenation script, running totals, etc.). Any standard USB cable allows me to transfer those to and from my workstation, where I maintain copies of the same scripts.

    Can't see a reason to go any more complex than storing them in the file system.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hi,

    I have a seperate database for all my "utility" scripts, stored as procedures.

    I seperate the funtionality of each script with schemas.

    It's good because you can automate the backups which are then portable and it requires no extra effort to open windows folders or third-party software etc... simple solution.

    :w00t:

  • Shabba (10/30/2009)


    Thanks for all the responses. Lowell that's exactly what i'm after do you know of a free alternative to EditPlus?

    Cheers,

    Mark

    the unregisted version of Editplus is free, with only a single nag screen at startup. it is completely full featured, with just a reminder screen .

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • the unregisted version of Editplus is free, with only a single nag screen at startup. it is completely full featured, with just a reminder screen .

    hmmm... can only seem to find the 30 Day Evaluation Version?

  • Shabba (10/30/2009)


    the unregisted version of Editplus is free, with only a single nag screen at startup. it is completely full featured, with just a reminder screen .

    hmmm... can only seem to find the 30 Day Evaluation Version?

    yep that's it; i'm on day 1066 + of the 30 Day Evaluation Version. like i said, just a nag screen at startup. enjoy!

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I posted a similar question a few months ago... you may want to have a look at some of the suggestions there

    http://qa.sqlservercentral.com/Forums/Topic766956-61-1.aspx

  • yep that's it; i'm on day 1066 + of the 30 Day Evaluation Version. like i said, just a nag screen at startup. enjoy!

    LOL - thanks mate

    @ Ian Scarlett - I'll take a look, thanks.

  • I just re-installed notepad++ this morning with the intention of using it instead of notepad for all of my quick ad hoc notes to myself and possibly more. Does anyone know if it t has the same type of script library that I see in Lowell's screenshot? If not, I may be jumping on the EditPlus bandwagon. Not really in love with either yet, so the switch would be easy. Any other reasons to use one over the other?

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • I use Action Outline. It is wonderful and is very much like windows explorer with the tree / branch structure. I couldn't live without it. I keep all my code snippets in there.

    http://www.actionoutline.com/

Viewing 15 posts - 1 through 14 (of 14 total)

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