Tutorial :How do you remember/manage your SQL examples?



Question:

I currently have a SQLTIPS.sql file, which lives on my hard disk, at work.

I'll add any new or nice examples, of writing good SQL, to this file. Now it's becoming hard to manage, and I have to search for specifics, in my own file!

I am looking for something that can be loaded in SQL Enterprise Manager quickly, something similar to Visual Studio IDE code snippets.


Solution:1

I have each example snippet stored in a separate .sql file, give it some meaningful name, and preferably some comments at top.

I use Dropbox to have it available on all machines I am using, and Google Desktop to search for what i need (the proper comments come handy then)


Solution:2

SQL Management Studio (SQL2005+) has snippets in it. You can use Management Studio on SQL 2000 and later


Solution:3

I blog about stuff I really want to remember...


Solution:4

I've found this T-SQL Factsheet is a good PDF to have pinned up around your desk!

Useful T-SQL Factsheet


Solution:5

I'd use the Template Explorer (Ctrl-Alt-T, or View | Template Explorer) in SQL Server Management Studio. There are a bunch of pretty good templates/examples there by default already, and you can easily add them, group them by function, etc. From there you can easily drag/drop them into scripts. There's even a search function (right-click, Search) within the explorer window.


Solution:6

In SQL Server 2005 and up, you can create one or multiple projects and group your scripts into SQL Server projects. Quite handy.

Or use the SQL Server templates in the Template Explorer - extremely helpful for keeping (nearly) every-day scripts at your finger tips!

Marc


Solution:7

We have a Wiki setup where we keep all of our SQL snippets that we use. It's searchable and easily updateable.

I should also say this doesn't replace our source control system. We keep all table changes, stored procedures etc. in svn. We use the wiki for little scripts that we need to use on a frequent basis to alter data or run ad hoc queries in the system and also for things like tips and tricks that we want to keep track of.


Solution:8

I have a created a Study database and I keep all my study/example stuff there. Take care of all the good practices so that you can quickly find what you are searching for. Not sure if there exists some thing that helps managing the snippets for SQL as well.


Solution:9

I found that for the last 6 or 7 years or so I just keep a folder on my computer somewhere called 'SQL Scripts'. I've put every useful and useless snippet of SQL that I've ever found useful or interesting in it. I keep a copy of it on CD which I update more or less frequently to keep up to date.

I never bothered looking at the snippets control thru SSMS but I might have to try it. We use SQL Prompt from RedGate here and it has a snippet control so for things I use very frequently, like my object search script I just need to type FINDIT and it all comes up.


Solution:10

I have SYSTEM SCRIPTS in my SQL scripts folder categorized into folders (Performance, Tempdb, Security, Login, etc...)

name them with meaningful names use EditPlus to search text inside


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »