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. Other Discussions
  3. Clever Code
  4. SQL Server Query

SQL Server Query

Scheduled Pinned Locked Moved Clever Code
databasequestionsql-serversysadminhelp
26 Posts 10 Posters 26 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.
  • C Chris Losinger

    Rob Graham wrote:

    The underscore character is also a wildcard

    :wtf: that's just plain fncked up.

    image processing | blogging

    R Offline
    R Offline
    Rob Graham
    wrote on last edited by
    #21

    Maybe so, but is been that way since the earliest versions of SQL (and Sybase before that). Also applies to Microsoft Access, and is ANSI 92 standard [^]

    1 Reply Last reply
    0
    • R Rob Graham

      Guffa,I think you're being a bit padantic here. In the original post, Tim did allow for it to be his error rather than a bug. I would argue that even if one did read the docs (and BOL is only marginally better than MSDN), given the context of the _, it would be very easy to overlook it's meaning, and be confused by the results. The "bug is just like if(x=1) instead of if(x==1), both are a case of overooking an "obvious" error because of the context of the error...:rose:

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #22

      Rob Graham wrote:

      Guffa,I think you're being a bit padantic here.

      You mean pedantic. ;)

      --- b { font-weight: normal; }

      C 1 Reply Last reply
      0
      • G Guffa

        Rob Graham wrote:

        Guffa,I think you're being a bit padantic here.

        You mean pedantic. ;)

        --- b { font-weight: normal; }

        C Offline
        C Offline
        Chris Meech
        wrote on last edited by
        #23

        LOL. I'm temtpted to report the post as abuse, but correcting Rob's spelling of pedantic is too funny. :-D

        Chris Meech I am Canadian. [heard in a local bar] I agree with you that my argument is useless. [Red Stateler] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]

        1 Reply Last reply
        0
        • T Tim Carmichael

          Rama Krishna Vavilala wrote:

          Why are you not using sp_depends

          Because I didn't know about it until now... thank you! :-D

          J Offline
          J Offline
          Jasmine2501
          wrote on last edited by
          #24

          sp_depends sucks that's why - it tends to miss things. Your query is better. Your underscore in the query is matching whitespace, but two false-positives isn't so bad.

          "Quality Software since 1983!" http://www.smoothjazzy.com/

          1 Reply Last reply
          0
          • T Tim Carmichael

            Thank you... I have to regularly switch between SQLServer, Oracle, Ingres, and a third party product, and don't necessary remember all of the nuances of each... Every day we learn something new, we are the richer for it...

            J Offline
            J Offline
            Jasmine2501
            wrote on last edited by
            #25

            I don't know why it can't just use regex. That's bugged me for years.

            "Quality Software since 1983!" http://www.smoothjazzy.com/ - see the "Programming" section for (freeware) JazzySiteMaps, a simple application to generate .Net and Google-style sitemaps!

            1 Reply Last reply
            0
            • T Tim Carmichael

              Not exactly a subtle bug, but, perhaps a bug in SQLServer... I am trying to track down usage of a table before making changes to the application to ensure I don't break anything else. To find all of the stored procedures that use the table in question, I use the following query: SELECT o.name, c.number, c.text FROM sysobjects AS o INNER JOIN syscomments AS c ON o.id = c.id WHERE (o.xtype = 'P') and c.text like '%supplier_price%' order by 1 The query returns a number of stored procedures, but at least two of them to not have the text 'supplier_price' in them; what they have is 'supplier price'. So... is this a bug in SQLServer, or am I querying incorrectly? Tim

              C Offline
              C Offline
              Cristian Amarie
              wrote on last edited by
              #26

              Probably LIKE behaves like STUFF('%_%') ? That's why probably the query found 'supplier price' - replaced '_' with . Why using spaces in sp anyway? Much better, IMHO, to use first a prefix indicating the area of usage, followed by the purpose of sp, such as: SA_CreateInvoice (SA = SAles) WR_RetrieveItems (WR = WareHouse) PR_DeleteOrder (PR = PRoduction) AC_CreateRegistration (AC = ACcounting) and so on. (Actually, is FT = Fatturazione instead of sales, MG = Magazzino instead of warehouse etc. - I'm working for an italian company :) ) This is the kind of convention we use when naming stored procedures (tables, triggers etc).

              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