Search code examples
sqlsql-server-2005organization

Sharing Common SQL Queries Amongst a Team


I don't even want to think about how many man hours have been spent writing the same queries to join over the exact same tables at my company.

When I first started at my job I identified this as an inefficiency and started writing views in a separate schema for the sole purpose of developer convenience.
My boss didn't like this very much and recommended I start committing my common queries to source control in a separate folder from the production SQL. This makes sense because some scripts require parameters and not all are read only.

What is a Common Query?

  • Script used to diagnose certain problems
  • Script to view relationships between several tables (doing multiple joins)
  • Script that we don't want in a stored procedure because it is often tweaked to diagnose the issue of the day

Issues I want to Address

  • Discoverability, queries will be rewritten if nobody can find them
  • IDE integration, want to be able to easily view queries in IDE. I've tried the SQL Server Solutions but they really suck because they lock you into only working on that set of files.

I was wondering how all the pro's out there share their common SQL queries.

Thanks


Solution

  • Seems like the op wants to know how to get the word out to the team about useful SQL that others can/should use so not to recreate.

    How I have done this in the past is through two ways:

    1. Create a team web wiki page that details the SQL with examples of how it is used.
    2. Email the team when new SQL is created that should be shared.

    Of course, we always include the SQL code in version control, just the wiki and email are use in the "getting word out there" part.