Quotes of the day:
-
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.
-
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.
Why kind of monster can write such SQL?
-
Why kind of monster can write such SQL?
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 =|'
-
Why kind of monster can write such SQL?
this is why they created linq !
-
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 =|'
Brady Kelly wrote:
The reason for all the casts is historical
... Don't you mean hysterical :laugh:
-
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.
You have my utmost condolences... X|