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 Rusty Bullet

    My company uses SourceGear Vault Standard to store tables, stored procs, functions and queries, but I keep a folder of SQL named with a date and purpose. An example would be '20201201_RestoreDataForCustomer'. The date gives me a context to find them more quickly.

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

    Rusty Bullet wrote:

    An example would be '20201201_RestoreDataForCustomer'. The date gives me a context to find them more quickly.

    :thumbsup: That's one of the tricks I've employed too. but, it also seems to point to a problem that is begging for a management solution. Thanks

    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:

      A Offline
      A Offline
      AndrewGT
      wrote on last edited by
      #48

      Why not store them in a database? You could use SQL to find the best match... :)

      R 1 Reply Last reply
      0
      • R rnbergren

        I am always late to the party. HAHAHA. But then I get to read everyone elses comments before I make my own. What I use is a blend of notepad++ or SSMS and multiple fairly large what I call scratch files. For differing companies and projects I create a scratch SQL project which is mostly commented out sql that includes databases, SPs, Views etc... and then one or 15 differing select statements/kewl sql statements that work for this database scheme. Then I use Agent Ransack when I am searching for something esoteric that I need for a new client/project. It works for me and I usually end up cobbling something together from inside the scratch file then copying and pasting into a new SQL for the new SP or View and away I go. What works for you I guess. PS I do love Agent Ransack.

        To err is human to really mess up you need a computer

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

        rnbergren wrote:

        It works for me and I usually end up cobbling something together from inside the scratch file then copying and pasting into a new SQL for the new SP or View and away I go.

        Yep, that's what it's like. That's why this is interesting to me because it seems like there would be one good solution, but it takes a lot of work to bring together a good way to manage it all. Thanks for your input.

        rnbergren wrote:

        PS I do love Agent Ransack.

        another poster mentioned this and i'll be checking it out.

        1 Reply Last reply
        0
        • M Matt Bond

          I use grepWin on windows to search the content of files. Has regex capabilities too. I use it all the time to find old SQL queries in our installer's collection of SQL files. The secret is to put all the text files in the same (root) folder. Bond Keep all things as simple as possible, but no simpler. -said someone, somewhere

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

          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.

          1 Reply Last reply
          0
          • O obermd

            Save them as .sql files and give them good file names. Then organize them into folders. In other words, treat them like any other application source code.

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

            That's really the main way to do it. I just don't like sql too much, often forget it and find that since I only have to design queries every few years I am very bored by it. :-D So, if I could find a way to manage them so I could just find the one I want very easily I would be happy (and it would promote my laziness). :laugh:

            1 Reply Last reply
            0
            • A AndrewGT

              Why not store them in a database? You could use SQL to find the best match... :)

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

              Other Dev: What'cha doing? Me: Writing a SQL query to find a SQL query that I can use in this project. :rolleyes:

              1 Reply Last reply
              0
              • R raddevus

                I don't hate Java, actually. I really like Java as a language. Also, this sounds like the kind of thing that I was thinking might be going on out there -- custom solutions that help you design sql queries and manage them(for devs). :thumbsup:

                E Offline
                E Offline
                ElectronProgrammer
                wrote on last edited by
                #53

                I meant that you would hate the methodology of writing SQL using another language, not the language itself, since it is more work initially. You have to break the SQL code into pieces to insert variables in between, write the program code and document it. Most of the times I mention this methodology people look at me as if I just told them to program everything in assembly! I use Java for this since it is very easy to convert to a servlet and have the interface on a web page, although I prefer to use the command line. My knowledge of web technologies is limited and all my pages end up looking like :doh:

                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:

                  M Offline
                  M Offline
                  Marc Clifton
                  wrote on last edited by
                  #54

                  What, can't you just ask the computer "give me this data" and it writes the SQL query for you? "Hello, computer." "Use the keyboard? How archaic!" I hope y'all know what movie I'm quoting. ;)

                  Latest Articles:
                  Thread Safe Quantized Temporal Frame Ring Buffer

                  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:

                    M Offline
                    M Offline
                    Matt McGuire
                    wrote on last edited by
                    #55

                    evernote or onenote since they allow for naming sub tabs, I can categorize them, make it a little faster to search

                    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:

                      M Offline
                      M Offline
                      MSBassSinger
                      wrote on last edited by
                      #56

                      I use a private GitHub repo, and use Agent Ransack on my local laptop to find specific files by key words or phrases.

                      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:

                        C Offline
                        C Offline
                        cwjinc
                        wrote on last edited by
                        #57

                        Create views with meaningful names? Isn't that what views are for?

                        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:

                          C Offline
                          C Offline
                          Choroid
                          wrote on last edited by
                          #58

                          I wrote a little program called Code Vault it lets me name the snippet of code with a date saved and the code It is searchable from experience it needs a one character field where you enter C for create or U for Update need to rewrite it as it is in VB 6 Just a suggestion

                          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:

                            U Offline
                            U Offline
                            User 10911256
                            wrote on last edited by
                            #59

                            Why use text files? A database can store strings. So if you want searchable storage of queries why not make a table?

                            R 1 Reply Last reply
                            0
                            • M Marc Clifton

                              What, can't you just ask the computer "give me this data" and it writes the SQL query for you? "Hello, computer." "Use the keyboard? How archaic!" I hope y'all know what movie I'm quoting. ;)

                              Latest Articles:
                              Thread Safe Quantized Temporal Frame Ring Buffer

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

                              Marc Clifton wrote:

                              can't you just ask the computer "give me this data" and it writes the SQL query for you?

                              I know. It's quite annoying that I can't. Even Google Home (assistant) won't just tell me answers a lot of the time.

                              Marc Clifton wrote:

                              I hope y'all know what movie I'm quoting.

                              I tried DuckDuckGo and got nothing for those quotes. Maybe, War Games with Matthew Broderick? Or maybe Star Trek..."Computer...what is our heading?"

                              1 Reply Last reply
                              0
                              • M Matt McGuire

                                evernote or onenote since they allow for naming sub tabs, I can categorize them, make it a little faster to search

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

                                Matt McGuire wrote:

                                evernote or onenote since they allow for naming sub tabs, I can categorize them, make it a little faster to search

                                That's an interesting one. I think whatever organization system a dev finds that works for him/her is good. And most people in this thread have said this is basically what they do or just put them all in a text file. These methods just feel like only one step above keeping them in a plastic binder. :laugh: I wish there was a way to really categorize, organize, digitize and systematize the whole situation. But, I'm lazy and slow and I forget SQL all the time (because it is so forgetable). :laugh:

                                M 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:

                                  M Offline
                                  M Offline
                                  Mark Starr
                                  wrote on last edited by
                                  #62

                                  So, it depends on which interface you're using. If you're using Management Studio you can save frequently-used queries in 2 places (I've used both over the years): 1) Create a 'Project' (File / New / Project / SQL Server Scripts) and save .SQL files into that project. Kinda clunky for organization, but workable. I used this method as a default, and used file naming for file sorting and commented keywords for searches. Sometimes you have to open the project file and manually rearrange the file references. 2) use the Code Snippets Manager (Tools / Code Snippet Manager) You can create your own Groups and add scripts to existing or new Groups. pretty handy, a little clunky, but it works. I used this area for some very-frequently-used utility scripts. If this info is coming to you late, well - I read your thread early this morning, but didn't get to my computer till now. Take it for what its worth. Cheers,

                                  Time is the differentiation of eternity devised by man to measure the passage of human events. - Manly P. Hall Mark Just another cog in the wheel

                                  M R 2 Replies Last reply
                                  0
                                  • M MSBassSinger

                                    I use a private GitHub repo, and use Agent Ransack on my local laptop to find specific files by key words or phrases.

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

                                    MSBassSinger wrote:

                                    I use a private GitHub repo, and use Agent Ransack on my local laptop to find specific files by key words or phrases.

                                    That's a good combination. Easy to get to from anywhere on the Internet and also you can search them. I'm going to have to look into this agent ransack thing, but the word "ransack" has really put me off it. Many here have mentioned agent ransack.

                                    1 Reply Last reply
                                    0
                                    • M Mark Starr

                                      So, it depends on which interface you're using. If you're using Management Studio you can save frequently-used queries in 2 places (I've used both over the years): 1) Create a 'Project' (File / New / Project / SQL Server Scripts) and save .SQL files into that project. Kinda clunky for organization, but workable. I used this method as a default, and used file naming for file sorting and commented keywords for searches. Sometimes you have to open the project file and manually rearrange the file references. 2) use the Code Snippets Manager (Tools / Code Snippet Manager) You can create your own Groups and add scripts to existing or new Groups. pretty handy, a little clunky, but it works. I used this area for some very-frequently-used utility scripts. If this info is coming to you late, well - I read your thread early this morning, but didn't get to my computer till now. Take it for what its worth. Cheers,

                                      Time is the differentiation of eternity devised by man to measure the passage of human events. - Manly P. Hall Mark Just another cog in the wheel

                                      M Offline
                                      M Offline
                                      Mark Starr
                                      wrote on last edited by
                                      #64

                                      Oh, by the way: if you use Option 1 (SQL files and SQL Project) you can use version control so as to not lose files or their contents.

                                      Time is the differentiation of eternity devised by man to measure the passage of human events. - Manly P. Hall Mark Just another cog in the wheel

                                      1 Reply Last reply
                                      0
                                      • C cwjinc

                                        Create views with meaningful names? Isn't that what views are for?

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

                                        That's a good thing. I'm more talking about a way to get to old SQL queries / Stored Procs (SP) I've written in past to solve problems which I can use again to solve new problems --- after slightly altering them. I'm talking about query design and SP creation and managing these old queries I have worked through to get to the answer. I often create some cool query and then 3 years from now I totally forget how i did it.

                                        C 1 Reply Last reply
                                        0
                                        • C Choroid

                                          I wrote a little program called Code Vault it lets me name the snippet of code with a date saved and the code It is searchable from experience it needs a one character field where you enter C for create or U for Update need to rewrite it as it is in VB 6 Just a suggestion

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

                                          Yeah a SQL-Vault is the type of thing I'm talking about. It would be nice.

                                          C 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