简体   繁体   中英

How can I programmatically determine if the installed SQL Server is 32 or 64 bit

I'm trying to programmatically determine if an installed instance of SQL Server (2005-2012) is 32 or 64 bit in C#. I've looked through the registry and have not found anything and I don't want to base it off whether it is installed in Program Files (x86) since they may have installed it elsewhere. Is there any where else I can look?

Edit: I won't know if I'm able to connect to the instance, so running a query won't always be possible.

Thanks

You can use the file properties for the instance you want to look at.

C:\\Program Files\\Microsoft SQL Server\\MSSQL10_50.MSSQLSERVER\\MSSQL\\Binn\\sqlservr.exe

The file description will indicate if it's 64 bit.

"SQL Server Windows NT - 64 bit"

Open a SQL Command to the instance and run the below. If you are looking for a file based approach. It is a little different.

SELECT @@VERSION

This will tell you what you need to know. An example output would be

Microsoft SQL Server 2008 R2 (SP3) - 10.50.6220.0 (X64) Mar 19 2015 12:32:14 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 (Build 7600: ) (Hypervisor)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM