I
I
Igor2014-06-26 11:58:02
Transact SQL
Igor, 2014-06-26 11:58:02

How to properly store T-SQL code snippets?

Hello dear!
I am a software support specialist that works with Microsoft SQL Server databases.
At the moment I have a large dump of files with solutions for various kinds of errors. Software products are quite capacious (from 20 to 100 sections with a large number of tabs), but, unfortunately, I do not know how to properly structure queries for convenient and quick access to them and further use in my work.
Tried several options:
Storage using projects in SQL Management Studio:

<Project 1>
--filename1.sql
---filename2.sql
-- ...
-- filename50.sql
<Project 2>
<Project ...>
<Project 10>

But in production, it all looks like a pile of garbage, in which it's hard to find something.
I would like to hear answers from knowledgeable people.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor, 2014-08-09
@rze

The most correct solution is to store the code in stored procedures.

A
AdvanTiSS, 2015-04-23
@AdvanTiSS

A good enough way is to install Visual Studio Data Tools, create a separate DataBase project for each database, automatically generate each database's SQL DDL in the project, and add your files to the Scripts folder of the corresponding project. Everything will be stored in one place and have a convenient toolkit for editing SQL code. And finally, the entire solution should be saved in the version control system (SVN, Git, Mercurial, etc.).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question