Tuesday, March 27, 2012

Determine if MSDE or SQL Express is installed?

Is there a best practice in determining whether MSDE installed on a
workstation or if SQL Express is installed? The SQL Express installs
are all with the default named instance of .\SQLExpress, but it's not
otherwise generally known as to which version is present.
Specifically, a (DOS) bat file is periodically launched to run a sql
script (via osql.exe). Somehow, the bat file needs to handle the
difference between the MSDE default instance and the SQL Express named
instance.
I thought of using the installed paths to make a decision in the bat
file, for instance:
IF EXIST "C:\Program Files\Microsoft SQL Server\90" GOTO :Express
:MSDE
osql.exe -S (local) -E -i myfile.sql -n
GOTO :EOF
:Express
osql.exe -S .\SQLExpress -E -i myfile.sql -n
('Course the second osql.exe reference above could be to sqlcmd.exe
instead).
Thanks!
Hi Mark
SQLPing will give you a list of instances but not the information on
editions see
http://www.sqlsecurity.com/Tools/FreeTools/tabid/65/Default.aspx
You could use SMO, sqlcmd or osql to get the edition information
SERVERPROPERTY ( 'edition')
or
SERVERPROPERTY ( 'Engine Edition' )
but you would need to connect to it to be able to query the server properties.
John
"Mark Lemoine" wrote:

> Is there a best practice in determining whether MSDE installed on a
> workstation or if SQL Express is installed? The SQL Express installs
> are all with the default named instance of .\SQLExpress, but it's not
> otherwise generally known as to which version is present.
> Specifically, a (DOS) bat file is periodically launched to run a sql
> script (via osql.exe). Somehow, the bat file needs to handle the
> difference between the MSDE default instance and the SQL Express named
> instance.
> I thought of using the installed paths to make a decision in the bat
> file, for instance:
> IF EXIST "C:\Program Files\Microsoft SQL Server\90" GOTO :Express
> :MSDE
> osql.exe -S (local) -E -i myfile.sql -n
> GOTO :EOF
> :Express
> osql.exe -S .\SQLExpress -E -i myfile.sql -n
> ('Course the second osql.exe reference above could be to sqlcmd.exe
> instead).
> Thanks!
>

No comments:

Post a Comment