patternMinor
Can I Set The Value of App_Name() AFTER Login?
Viewed 0 times
aftercantheapp_nameloginvalueset
Problem
I've got an older application that is connecting via ODBC to my database server. I want to discover what the Application Name is inside a stored procedure. I'm not able to set the Application Name (or the ProgramName value in xp_who2) at login due to the ODBC ware not supporting it. Is it possible to set that value after login via some "set" command?
I understand there are other ways around this (like calling my stored procedure with the application name) but I'm hoping to avoid that as it would require more than one coding change, and rather do something for this session just after login.
I understand there are other ways around this (like calling my stored procedure with the application name) but I'm hoping to avoid that as it would require more than one coding change, and rather do something for this session just after login.
Solution
What about using SET CONTEXT_INFO? It takes a varbinary(128) value, but you can easily cast that to/from varchar or whatever is appropriate. Read it back from sysprocesses.
http://msdn.microsoft.com/en-us/library/aa259199(v=sql.80).aspx
http://msdn.microsoft.com/en-us/library/aa259199(v=sql.80).aspx
Context
StackExchange Database Administrators Q#15831, answer score: 5
Revisions (0)
No revisions yet.