April 29, 2009 at 2:06 pm
Hello,
I have been implementing some session source tracking on our SQL servers, and am unclear on any difference between the APP_NAME() and PROGRAM_NAME() functions.
Most of the code examples I find online use the PROGRAM_NAME() function, but I can't find any mention in books online or MSDN, which both describe the APP_NAME() function.
In my testing they both seem to return the same results. I would guess that, since it is documented, APP_NAME would be preferred.
Has anyone experienced any practical difference between the two?
Thanks,
April 29, 2009 at 3:35 pm
Sibbs (4/29/2009)
Hello,I have been implementing some session source tracking on our SQL servers, and am unclear on any difference between the APP_NAME() and PROGRAM_NAME() functions.
Most of the code examples I find online use the PROGRAM_NAME() function, but I can't find any mention in books online or MSDN, which both describe the APP_NAME() function.
In my testing they both seem to return the same results. I would guess that, since it is documented, APP_NAME would be preferred.
Has anyone experienced any practical difference between the two?
Thanks,
I can find APP_NAME() in BOL,
Returns the application name for the current session if set by the application.
I can't find an entry in BOL for PROGRAM_NAME.
April 29, 2009 at 7:54 pm
Lynn Pettis (4/29/2009)
I can find APP_NAME() in BOL...I can't find an entry in BOL for PROGRAM_NAME.
Hey Lynn,
I remember this from years ago - PROGRAM_NAME does work, and returns the same result as APP_NAME - but I can't find documentation either. Even more strangely, selecting the two functions produces the following in a compute scalar:
[font="Courier New"][Expr1000] = Scalar Operator(program_name()), [Expr1001] = Scalar Operator(app_name())[/font]
..so they seem to be genuinely different, as opposed to say GET_DATE() and CURRENT_TIMESTAMP, which are both reported as GET_DATE().
Interesting stuff. In answer to the question though - use APP_NAME, it's safer.
Paul
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply