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. The Weird and The Wonderful
  4. Quotes of the day:

Quotes of the day:

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasetoolsannouncement
6 Posts 5 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.
  • B Offline
    B Offline
    Brady Kelly
    wrote on last edited by
    #1

    SELECT @ValueList = ''''+REPLACE(ISNULL(CAST([Amount] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([ActualCost] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([Notes] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([Qty1] as varchar(8000)),'Null'),'''','''''') + ''' FROM Documents I'm supposed to edit this, then place it in an update statement - it's the contents of a table field, not a literal query! I would rather write a quote doubler/divider than take my chances, but I was crafty and pasted my edit back into the field in Management Studio, now I just script the data of the table using the Publishing Wizard.

    T M 2 Replies Last reply
    0
    • B Brady Kelly

      SELECT @ValueList = ''''+REPLACE(ISNULL(CAST([Amount] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([ActualCost] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([Notes] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([Qty1] as varchar(8000)),'Null'),'''','''''') + ''' FROM Documents I'm supposed to edit this, then place it in an update statement - it's the contents of a table field, not a literal query! I would rather write a quote doubler/divider than take my chances, but I was crafty and pasted my edit back into the field in Management Studio, now I just script the data of the table using the Publishing Wizard.

      T Offline
      T Offline
      Tony Pottier
      wrote on last edited by
      #2

      Why kind of monster can write such SQL?

      B Y 2 Replies Last reply
      0
      • T Tony Pottier

        Why kind of monster can write such SQL?

        B Offline
        B Offline
        Brady Kelly
        wrote on last edited by
        #3

        It gets worse. When I escape the quotes to script an update of that field, I get the SQL below. The reason for all the casts is historical, and the reason for all the quotes is that the SQL gets passed through several layers of stored proc before actually being executed.

        UPDATE [csForm] SET [CopyCommand] = N'SELECT @ValueList = ''''''''+REPLACE(ISNULL(CAST([Amount] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([DocTitle] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''' FROM Documents WHERE DocID =|SELECT ''''''&IDENTITY&'''','''''' + REPLACE(ISNULL(CAST([WorkType] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([WorkTypeID] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([Amount] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([Notes] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([LineType] as varchar(8000)),''Null''),'''''''','''''''''''')+'''''''' AS ValueList FROM DocItems WHERE DocID =|'

        J 1 Reply Last reply
        0
        • T Tony Pottier

          Why kind of monster can write such SQL?

          Y Offline
          Y Offline
          yassir hannoun
          wrote on last edited by
          #4

          this is why they created linq !

          1 Reply Last reply
          0
          • B Brady Kelly

            It gets worse. When I escape the quotes to script an update of that field, I get the SQL below. The reason for all the casts is historical, and the reason for all the quotes is that the SQL gets passed through several layers of stored proc before actually being executed.

            UPDATE [csForm] SET [CopyCommand] = N'SELECT @ValueList = ''''''''+REPLACE(ISNULL(CAST([Amount] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([DocTitle] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''' FROM Documents WHERE DocID =|SELECT ''''''&IDENTITY&'''','''''' + REPLACE(ISNULL(CAST([WorkType] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([WorkTypeID] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([Amount] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([Notes] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([LineType] as varchar(8000)),''Null''),'''''''','''''''''''')+'''''''' AS ValueList FROM DocItems WHERE DocID =|'

            J Offline
            J Offline
            Jeremy Tierman
            wrote on last edited by
            #5

            Brady Kelly wrote:

            The reason for all the casts is historical

            ... Don't you mean hysterical :laugh:

            1 Reply Last reply
            0
            • B Brady Kelly

              SELECT @ValueList = ''''+REPLACE(ISNULL(CAST([Amount] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([ActualCost] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([Notes] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([Qty1] as varchar(8000)),'Null'),'''','''''') + ''' FROM Documents I'm supposed to edit this, then place it in an update statement - it's the contents of a table field, not a literal query! I would rather write a quote doubler/divider than take my chances, but I was crafty and pasted my edit back into the field in Management Studio, now I just script the data of the table using the Publishing Wizard.

              M Offline
              M Offline
              Megidolaon
              wrote on last edited by
              #6

              You have my utmost condolences... X|

              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