General information
Forum:
Microsoft SQL Server
>>As Replace fails, my gut hunch to force
>>CHAR(34)+substring(" " + rtrim(Table.Field), 2, 999999)+CHAR(34)
>>will probably fail as well - but easy to check...
>
>Ok, I'm impressed.
Don't be. If my hunches in the long run would work with females as well as with machines, that would be awesome ;-) Too bad that they sometimes fail in spectacular way.
>As I have quotes in that field, I added REPLACE(Table.Field,'"','') in order to avoid a conflict.
>This works. But, what does it do exactly?
Uses Belt, Suspenders and Chastity girdle to force a string, as your
CHAR(34)+'Hello'+CHAR(10)+'World'+CHAR(34)
worked, but Replace() failed and eliminates side effects perhaps caused by your replace as well
.
So using only functions which in wee times of differing SQL dialects either were missing or already were guaranteed to be working on strings only should do the same - if some very old code allowed replace to do other things as well, that might cause hickups or the replacement worked like wrong SQL injection.
Curious minds might now abolish some parts of working statement
CHAR(34)+substring(" " +Table.Field, 2, 999999)+CHAR(34)
CHAR(34)+rtrim(Table.Field)+CHAR(34)
CHAR(34)+cast(Table.Field as ...)+CHAR(34)
CHAR(34)+stuff(Table.Field, with no working, "whatever")+CHAR(34)
CHAR(34)+stuff(Table.Field, working, "whatever")+CHAR(34)
to discern a pattern ;-)
Of course sometimes my gut hunches are correct and my mental reasoning after the fact is totally off base. It is a weird way to operate if you are normally proud on the workings of the matter between your ears...
best regards
thomas
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only