views:

223

answers:

2

How can you detect if your sql-server 2005 instance is a 32 or 64 bit instance from C# code? If you know some documentation on this issue, please let me know.. Thanks!

A: 

I'm curious... why?

Lazarus
Optimizations fine tuning..
E.
+1  A: 

Use SERVERPROPERTY ( propertyname )

With property name Edition.

64-bit versions of the Database Engine append (64-bit) to the version.

SELECT SERVERPROPERTY ( 'Edition' )

For me on my x64 machine returns the following string value: Enterprise Edition (64-bit)

You could also check the env variable PROCESSOR_ARCHITECTURE to see what the machine itself is running as.

Brian R. Bondy
Is this listed also on the registry or can be concluded from a file version? I need a way to do this not assuming I have a valid connection.
E.
updated answer with PROCESSOR_ARCHITECTURE note. I'm not 100% sure if you can install an x86 SQL on an x64 though. But I don't think you can.
Brian R. Bondy