Comments posted to this topic are about the item Getting the CONTEXT_INFO()
Follow me on Twitter: http://www.twitter.com/way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Good question, thanks Steve.
Nice question, thanks Steve
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
set CONTEXT_INFO 55
SELECT cast(substring(CONTEXT_INFO(),1,4) as int)
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
lmalatesta - Tuesday, February 27, 2018 8:26 AM
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?
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
Solomon Rutzky - Tuesday, April 10, 2018 11:10 AM
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)