question

Adrian Heald avatar image
Adrian Heald asked

dot net clr function for 64 bit SQL Server

Hi All,

When creating a CLR function for SQL Server do I need to compile two separate versions, one for 32 bit and one for 64 bit SQL server instances?

clruser-defined-function64-bit
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pavel Pawlowski avatar image
Pavel Pawlowski answered

What Matt said is true if you do not make a call to some assembly targeted to a specific platform or an unmanaged code for specific platform.

If you compile CLR assembly targetting it to AnyCpu and run this on x64 system, then it will be executed as x64 assebly. Although if you make a call to other unmanaged code or CLR assembly that is targeted to x86, then you will receive an exception of bad image format.

So if you need to call assemblies for different platforms, then you have to make two separate builds.

If you will have clear .NET code in the assembly and all will be targeted for AnyCpu, then you need only one build targeted for AnyCpu.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
+1 - yep definitely a clearer answer than mine! :)
0 Likes 0 ·
Matt Whitfield avatar image
Matt Whitfield answered

No, CLR code compiles to CIL / MSIL and the common language runtime handles it's targetting to the relevant processor type.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.