Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Controversial: SQL

Controversial: SQL

Scheduled Pinned Locked Moved The Lounge
database
76 Posts 34 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raddevus
    wrote on last edited by
    #1

    There is no good way to store good SQL queries for future use. Just, no good way. :rolleyes:

    OriginalGriffO J D W S 24 Replies Last reply
    0
    • R raddevus

      There is no good way to store good SQL queries for future use. Just, no good way. :rolleyes:

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      I keep a text file of 'em: "GoodSQLQueries.txt" it's called. It's easy to copy'n'paste 'em when I need 'em. Or just use an SP. What's the problem?

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      R B 2 Replies Last reply
      0
      • R raddevus

        There is no good way to store good SQL queries for future use. Just, no good way. :rolleyes:

        J Offline
        J Offline
        Jorgen Andersson
        wrote on last edited by
        #3

        I'm not sure I follow, would you mind expanding?

        Wrong is evil and must be defeated. - Jeff Ello Never stop dreaming - Freddie Kruger

        R 1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          I keep a text file of 'em: "GoodSQLQueries.txt" it's called. It's easy to copy'n'paste 'em when I need 'em. Or just use an SP. What's the problem?

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

          R Offline
          R Offline
          raddevus
          wrote on last edited by
          #4

          Well, I have something like that too, but it's difficult to find the right one amidst all of the other chaff. I wish there was a way to categorize them or something like that. And don't offer me the idea of making sections in my text file, cuz i'm lazy (of course -- I'm a dev). :-D

          OriginalGriffO O 2 Replies Last reply
          0
          • J Jorgen Andersson

            I'm not sure I follow, would you mind expanding?

            Wrong is evil and must be defeated. - Jeff Ello Never stop dreaming - Freddie Kruger

            R Offline
            R Offline
            raddevus
            wrote on last edited by
            #5

            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? :)

            J R Richard DeemingR 3 Replies Last reply
            0
            • R raddevus

              Well, I have something like that too, but it's difficult to find the right one amidst all of the other chaff. I wish there was a way to categorize them or something like that. And don't offer me the idea of making sections in my text file, cuz i'm lazy (of course -- I'm a dev). :-D

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              :-O I have sections in my text file ... because I'm lazy ... :laugh:

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              R 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                :-O I have sections in my text file ... because I'm lazy ... :laugh:

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                R Offline
                R Offline
                raddevus
                wrote on last edited by
                #7

                OriginalGriff wrote:

                I have sections in my text file ... because I'm lazy ...

                :thumbsup: That made me laugh too. I would like: 1) way to pick tables and fields (returned in query) 2) have notes that remind me what the query does 3) have a good way to find them again -- this wouldn't be easy to do I end up saving large SQL text files all over the place and then later searching through them and it takes just about as long to find them as it does to just think it all out again. I'm just wishing over here. :-D It would be very difficult to really create a good organizer. I guess I'm even lazier than I thought. (which I didn't think was possible)

                R M U 3 Replies Last reply
                0
                • R raddevus

                  There is no good way to store good SQL queries for future use. Just, no good way. :rolleyes:

                  D Offline
                  D Offline
                  Dan Neely
                  wrote on last edited by
                  #8

                  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

                  K R 2 Replies Last reply
                  0
                  • R raddevus

                    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? :)

                    J Offline
                    J Offline
                    Jorgen Andersson
                    wrote on last edited by
                    #9
                    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

                    R 1 Reply Last reply
                    0
                    • D Dan Neely

                      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

                      K Offline
                      K Offline
                      k5054
                      wrote on last edited by
                      #10

                      Possibly you need something like [Zim - a desktop wiki](https://zim-wiki.org/)

                      Keep Calm and Carry On

                      1 Reply Last reply
                      0
                      • R raddevus

                        There is no good way to store good SQL queries for future use. Just, no good way. :rolleyes:

                        W Offline
                        W Offline
                        W Balboos GHB
                        wrote on last edited by
                        #11

                        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

                        R 1 Reply Last reply
                        0
                        • R raddevus

                          There is no good way to store good SQL queries for future use. Just, no good way. :rolleyes:

                          S Offline
                          S Offline
                          Slacker007
                          wrote on last edited by
                          #12

                          not sure if this is even relevant or helpful: Transact-SQL Code Snippets - SQL Server Management Studio (SSMS) | Microsoft Docs[^] I save my sql to an organized sql folder locally, of which you could add to source control or cloud storage if you wanted to. it's not the greatest method, but I have been doing it this way for years and will probably not change. :-D

                          R 1 Reply Last reply
                          0
                          • R raddevus

                            OriginalGriff wrote:

                            I have sections in my text file ... because I'm lazy ...

                            :thumbsup: That made me laugh too. I would like: 1) way to pick tables and fields (returned in query) 2) have notes that remind me what the query does 3) have a good way to find them again -- this wouldn't be easy to do I end up saving large SQL text files all over the place and then later searching through them and it takes just about as long to find them as it does to just think it all out again. I'm just wishing over here. :-D It would be very difficult to really create a good organizer. I guess I'm even lazier than I thought. (which I didn't think was possible)

                            R Offline
                            R Offline
                            Rick York
                            wrote on last edited by
                            #13

                            Visual has/had a code snippets kind of thing. Maybe that could be adapted.

                            "They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"

                            OriginalGriffO 1 Reply Last reply
                            0
                            • W W Balboos GHB

                              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

                              R Offline
                              R Offline
                              raddevus
                              wrote on last edited by
                              #14

                              W∴ Balboos, GHB wrote:

                              Put them into a database.

                              well i have them in excel so ive already done that.😄

                              1 Reply Last reply
                              0
                              • S Slacker007

                                not sure if this is even relevant or helpful: Transact-SQL Code Snippets - SQL Server Management Studio (SSMS) | Microsoft Docs[^] I save my sql to an organized sql folder locally, of which you could add to source control or cloud storage if you wanted to. it's not the greatest method, but I have been doing it this way for years and will probably not change. :-D

                                R Offline
                                R Offline
                                raddevus
                                wrote on last edited by
                                #15

                                "This is the way." ~Mandalorian probably best way for me too

                                M 1 Reply Last reply
                                0
                                • R Rick York

                                  Visual has/had a code snippets kind of thing. Maybe that could be adapted.

                                  "They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"

                                  OriginalGriffO Offline
                                  OriginalGriffO Offline
                                  OriginalGriff
                                  wrote on last edited by
                                  #16

                                  You can also set it up in the VS toolbox as boilerplate code to drag and drop into an app - I use it for boilerplate SQL access to be "tuned" for a specific purpose.

                                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                  1 Reply Last reply
                                  0
                                  • R raddevus

                                    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? :)

                                    R Offline
                                    R Offline
                                    realJSOP
                                    wrote on last edited by
                                    #17

                                    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

                                    1 Reply Last reply
                                    0
                                    • D Dan Neely

                                      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

                                      R Offline
                                      R Offline
                                      raddevus
                                      wrote on last edited by
                                      #18

                                      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. :laugh:

                                      1 Reply Last reply
                                      0
                                      • R raddevus

                                        "This is the way." ~Mandalorian probably best way for me too

                                        M Offline
                                        M Offline
                                        Mycroft Holmes
                                        wrote on last edited by
                                        #19

                                        MSSQL snippets works perfectly for me except you need to rabbit through the category folders to find the exact one you need :-O. 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

                                        1 Reply Last reply
                                        0
                                        • J Jorgen Andersson
                                          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

                                          R Offline
                                          R Offline
                                          raddevus
                                          wrote on last edited by
                                          #20

                                          Jörgen Andersson wrote:

                                          1. 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.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups