July 27, 2017 at 10:51 pm
Comments posted to this topic are about the item Converting XML
July 27, 2017 at 10:51 pm
Nice simple to end the week on thanks Steve.
...
July 27, 2017 at 11:40 pm
Nice one to end the week on, thanks Steve
Interesting that TRY_CONVERT doesn't return a NULL in this instance, as it does for most other scenarios, e.g. select TRY_CONVERT(INT, 'Hello')
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
July 28, 2017 at 2:04 am
Quick correction,
select TRY_CONVERT(XML, '')
returns an empty output, not NULL as stated in the question.
😎
July 28, 2017 at 2:12 am
Thanks for reminding me why I never use this function!
July 28, 2017 at 7:06 am
Stewart "Arturius" Campbell - Thursday, July 27, 2017 11:40 PMNice one to end the week on, thanks SteveInteresting that TRY_CONVERT doesn't return a NULL in this instance, as it does for most other scenarios, e.g.
select TRY_CONVERT(INT, 'Hello')
It returned a NULL for me when I ran it on my SQL 2012 machine (SP3 CU9).
July 28, 2017 at 8:27 am
Tom_Hogan - Friday, July 28, 2017 7:06 AMStewart "Arturius" Campbell - Thursday, July 27, 2017 11:40 PMNice one to end the week on, thanks SteveInteresting that TRY_CONVERT doesn't return a NULL in this instance, as it does for most other scenarios, e.g.
select TRY_CONVERT(INT, 'Hello')
It returned a NULL for me when I ran it on my SQL 2012 machine (SP3 CU9).
I had the same result as Stewart when I ran it in SQL 2016 SP1. Maybe they changed it in 2016?
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
July 28, 2017 at 8:48 am
I ran SELECT TRY_CONVERT(XML,'') on SSMS 2016, 2014, and 2012 and none of them return NULL.
July 28, 2017 at 8:52 am
trvudat - Friday, July 28, 2017 8:48 AMI ran SELECT TRY_CONVERT(XML,'') on SSMS 2016, 2014, and 2012 and none of them return NULL.
That's because you can cast an empty string as XML.
August 1, 2017 at 5:30 am
bmg002 - Friday, July 28, 2017 8:27 AMTom_Hogan - Friday, July 28, 2017 7:06 AMStewart "Arturius" Campbell - Thursday, July 27, 2017 11:40 PMNice one to end the week on, thanks SteveInteresting that TRY_CONVERT doesn't return a NULL in this instance, as it does for most other scenarios, e.g.
select TRY_CONVERT(INT, 'Hello')
It returned a NULL for me when I ran it on my SQL 2012 machine (SP3 CU9).
I had the same result as Stewart when I ran it in SQL 2016 SP1. Maybe they changed it in 2016?
Nope. I just ran it on SQL 2016 SP1 and it returned a NULL.
August 1, 2017 at 9:08 am
Ohh, thanks for information, bacause I did not understand(((((
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply