|
Yeah this is the way most SQL solutions that people have mentioned are done. Text files in a directory, maybe use a file naming convention and then a search tool to find stuff in the SQL itself. It all works and you can wrap a process around it. It just seems like there would be a nice tool.
|
|
|
|
|
Could you store them in a table? You will need to do data entry no matter which solution you choose, so keeping them in a utilities database or table would work as well as anything else.
|
|
|
|
|
Then amend your post and write: "there is no good way for a lazy dev to keep track of good SQL queries"....
|
|
|
|
|
I use OneNote -- I have a notebook for each database, with sections labeled by tables and/or area. Each query or code segment has a comment briefing describing what it does. This makes hunting for things much easier.
|
|
|
|
|
I'm not sure I follow, would you mind expanding?
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
There's no great way to :
1) store and categorize good sql
2) also would like a way to insert table names and field names so you could select some things and then just fire off the SQL.
3) need a place for notes about what the sql actually does.
I tend to forget sql very fast -- sql is boring and declarative and I always have to look at it too much to remember what it does. Sometimes I just want to find an old query that does that thing you know?
|
|
|
|
|
1) I simply use the file system. Every file gets a [declarative name].sql, so you can doubleclick and it will start SSMS or whatever program is associated. The master folder is also added to TortoiseHg for versioning
2) Then you need to use dynamic SQL, which is a whole can of worms by itself, and also a possible source of so called SQL-injection
3) I use a fancy invention called Comments for that. Just add them to forementioned Files
In Oracle you can also add comments directly to the tables and columns themselves, but in SQL Server you only have Extended Properties, which aren't nearly the same thing
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
Jörgen Andersson wrote: 2) Then you need to use dynamic SQL, which is a whole can of worms by itself, and also a possible source of so called SQL-injection
I'm just talking about a local resource that I would use to call up previous queries that I've had to do to examine or update data manually. All of our work is done view SPs -- there are no ad-hoc SQL that are allowed to run against our DBs.
|
|
|
|
|
We have a database for saving queries like that as stored procs. Everybody has their own schema, and can see each other's procs. Most of them are specific to the table/view being queried.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
|
That's a good one. I'm checking it out. After looking at a couple of those templates I see where they got some of the boilerplate that they use in our RoundhousE[^] scripts.
Thanks, I will look more closely at this one.
|
|
|
|
|
My current project has a folder in google drive (coworkers choice, I'd've added a folder in our git repo) to store all the supposedly 1 off queries (if they said they wanted it repeatedly we'd have a report/import page) we've ran for the customer so they're available for the next time they ask.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
|
Yeah, I did something similar by creating a document on Google Drive. Just wish there was a better way to manage them with comments etc. By "better way", I mean i could just think of a query I've done in the past and it would appear on my screen.
|
|
|
|
|
The solution to your problem with storage, retrieval and categorizations is obvious:
Put them into a database.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
W∴ Balboos, GHB wrote: Put them into a database.
well i have them in excel so ive already done that.😄
|
|
|
|
|
|
"This is the way."
~Mandalorian
probably best way for me too
|
|
|
|
|
MSSQL snippets works perfectly for me except you need to rabbit through the category folders to find the exact one you need . Tis a bitch when you can't remember the category/folder it lives in.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Quote: There is no good way to store good SQL queries for future use.
What's wrong with stored procedures?
|
|
|
|
|
Member 13301679 wrote: What's wrong with stored procedures?
I mean like a development studio type of thing where you can select a particular SQL statement that you want to run manually when you're examining data and designing queries.
We use SPs for all interactions with DB but I'm talking more about a code reuse type of thing.
I guess I could create a library of SPs and then run those when I need to, but I'd still need a way to manage them with names and stuff so I could remember what they do.
I guess it is really because I'm in the midst of designing queries for a large system and I only have to do this every 2 or 3 years so I have a long time away from it.
|
|
|
|
|
Quote: I mean like a development studio type of thing where you can select a particular SQL statement that you want to run manually when you're examining data and designing queries.
MySQL Workbench allows that, including loading and saving the files just like an IDE, keeping files in different tabs, etc.
|
|
|
|
|
Looks interesting. I'm checking that one out. Looks similar to SSMS (Sql Server Mgmnt Studio)
|
|
|
|
|
|
That does look good but...
Link provided said Important
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
|
|
|
|