February 26, 2018 at 8:34 pm
Comments posted to this topic are about the item Getting the CONTEXT_INFO()
February 26, 2018 at 8:35 pm
Good question, thanks Steve.
...
February 26, 2018 at 11:03 pm
Nice question, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
February 27, 2018 at 12:59 am
set CONTEXT_INFO 55
SELECT cast(substring(CONTEXT_INFO(),1,4) as int)
February 27, 2018 at 8:26 am
The pedant in me would like to point out that you are getting 55 back, just not in a base 10 integer format.
If you're not getting back the same value when you context_info(), keep in mind these things about the stored value:
1. It's global to the session id, so it's possible to fall out of scope, maybe your application has closed the SQL connection and re-opened it in which case the previous value is lost forever
2. There is only a single structure so it's possible to overwrite, maybe your application has subsequently updated the value in which case the previous value is gone forever
April 10, 2018 at 11:10 am
lmalatesta - Tuesday, February 27, 2018 8:26 AMThe pedant in me would like to point out that you are getting 55 back, just not in a base 10 integer format.
Hi there. Actually, in this case you aren't exactly getting 55 back. I mean, the value is in there somewhere, just not where it needs to be for doing a simple convert back to INT. It's an "issue" with how the CONTEXT_INFO() built-in function returns the context_info value. I just wrote a post explaining this behavior:
Why Doesn’t CONTEXT_INFO() Return the Exact Value Set by SET CONTEXT_INFO?
Take care,
Solomon...
SQL# — https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
Sql Quantum Lift — https://SqlQuantumLift.com/ ( company )
Sql Quantum Leap — https://SqlQuantumLeap.com/ ( blog )
Info sites — Collations • Module Signing • SQLCLR
April 10, 2018 at 11:37 am
Solomon Rutzky - Tuesday, April 10, 2018 11:10 AMlmalatesta - Tuesday, February 27, 2018 8:26 AMThe pedant in me would like to point out that you are getting 55 back, just not in a base 10 integer format.Hi there. Actually, in this case you aren't exactly getting 55 back. I mean, the value is in there somewhere, just not where it needs to be for doing a simple convert back to INT. It's an "issue" with how the CONTEXT_INFO() built-in function returns the context_info value. I just wrote a post explaining this behavior:
The pedant in me would like to point out that "getting 55 back" and "getting 55 back in a way that is simple to convert back to INT" are two different things. Getting 55 back as a varbinary value padded by 0s that requires some fiddling is still getting 55 back.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy