Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exporting to Excel
Message
From
10/10/2021 16:53:10
 
 
To
10/10/2021 09:06:19
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01682467
Message ID:
01682476
Views:
43
>>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
Map
View

Click here to load this message in the networking platform