tags:

views:

148

answers:

3

Is it possible to enumerate the currently-defined session variables? I've been looking for the equivalent of

select * from sys.tables

for session variables, but I can't find a sys view that contains that information. I'm wondering if it's possible to spin through them and print them to the response window. I've got about 35+.

A: 

If you mean Session vars as in ASP.net, then NO.

callisto
I am not referring to asp.net. I am referring to SQL.
yodaj007
+2  A: 

No its not possible to retrieve that information from SQL Server.

KeeperOfTheSoul
+1  A: 

Try out this DMV. It has all the current session variables plus their values. They are in columnar format, btw. This will return the info on your current connection:

select * from sys.dm_exec_sessions where session_id = @@SPID

Also, here is the Books online article to interpret the columns (e.g. ansi_defaults column = ANSI_DEFAULTS setting for the session):

http://msdn.microsoft.com/en-us/library/ms176013(SQL.90).aspx

Strommy
While it's not quite what I was looking for, that's some good information, and your answer wasn't "no you can't". So I've accepted your answer.
yodaj007
Lol! Thanks yodaj007.
Strommy