T. Dingess
T. Dingess

Reputation: 53

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

Upvotes: 1

Views: 656

Answers (2)

Greg
Greg

Reputation: 152

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"

Upvotes: 1

John Specko
John Specko

Reputation: 307

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)

Upvotes: 0

Related Questions