Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Sql Express From TSQL

I need a safe (i.e consistent, robust) way of detecting whether or not the sql server I'm accessing is Sql Express. I think I'd prefer to be able to do this from TSQL, since I already have a connection string and all the libraries I need to execute TSQL (this should help avoid issues with whether or not WMI is installed/running, the user has permissions to access the registry etc).

Does anyone know of a way to do this ?

Thanks.

PS: Basically I want to do this so I can monitor my database size against the 4gb limit and take action when I approach it... but if I'm running on a full Sql Server edition then I don't want the code to worry about it since there is no (practical) hard coded limit. I could put in a manual setting in my program, but it would be much nicer if the code just did the right thing automatically, hence the need to know if the server is the 'Express' edition or not.

like image 386
Yort Avatar asked Jul 16 '09 15:07

Yort


People also ask

What version of SQL Express am I running?

OSQL –S servername\instancename –Usa If you have successfully logged into the SQL server a 1> will display. At the 1> type select @@version and press enter. At the 2> type go. Press Enter.

How can check SQL version from command line?

Use the following steps from the command prompt to determine what version of SQL you are running. On the workstation that SQL is installed, choose Start > Run, and enter cmd in the Open field, and then press Enter to launch a command prompt window. Type select @@version and press Enter.


1 Answers

Use

SELECT SERVERPROPERTY('EditionID')

or

SELECT SERVERPROPERTY('Edition')

to detect which version of SQLServer is running.

http://msdn.microsoft.com/en-us/library/ms174396.aspx

like image 131
devio Avatar answered Sep 30 '22 15:09

devio