Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which version of .NET framework SQL Server supports?

I want to create SQLCLR based stored procedures for SQL Server. As you know I can build a dll against multiple versions of .NET framework. I can't find a reference that describe which version of SQL Server supports which version of .NET framework. Can anyone help to point me the right direction?

like image 442
Just a learner Avatar asked Dec 13 '16 05:12

Just a learner


People also ask

What version of .NET does SQL Server 2019 use?

SQL Server 2019 requires the .Windows Server 2016 comes pre-installed with this version of the . NET Framework, but you may have to install it on older Windows Server versions.

Does SQL Server need .NET framework?

Summary. Different versions of Microsoft SQL Server have different . NET Framework versions as a prerequisite for setup, and the procedure to install the . NET Framework may be different on different operating systems.

Which is the minimum version of .NET framework is required for SQL Server 2017?

You'll need . NET Framework 3.5 too. Turns out if you plan on using Database Mail for your SQL Server, you'll also need to install . NET Framework 3.5.

Which version of .NET framework should I use?

You need whatever versions of . Net Framework are required by the applications you have and want to run properly. Usually, the required version will be included in the application's installer. If you are not experiencing any problems running applications, then you don't need to install any .

What version of NET Framework is supported on Windows 7?

.NET Framework 4.7 is supported on Windows 7, Server 2008 R2, Server 2012, 8.1, Server 2012 R2, 10, Server 2016 and Server 2019. .NET Framework 4.7 is also shipped as a Windows container image. .NET Framework 4.7.1 was released on 17 October 2017.

What version of common language runtime does the NET Framework use?

The .NET Framework 4.5 uses Common Language Runtime 4.0, with some additional runtime features. .NET Framework 4.5 is supported on Windows Vista, Server 2008, 7, Server 2008 R2, 8, Server 2012, 8.1 and Server 2012 R2.

What is the latest version of ASP NET Framework?

.NET Framework 4.7.2 was released on 30 April 2018. Amongst the changes are improvements to ASP.NET, BCL, CLR, ClickOnce, Networking, SQL, WCF, Windows Forms, Workflow and WPF. This version is included with Server 2019. .NET Framework 4.7.2 is also shipped as a Windows container image.

Which version of SQL Server does Visual Studio 2013 support?

Eg, instead of entering: MY-COMPUTER\SQLEXPRESS just enter MY-COMPUTER\ - this worked for me using SQL Server 2014 and Visual Studio Professional 2013 .NET supports any version of SQL Server from at least version 2000 onwards..... it depends on which edition you installed, and what instance name you picked for the server when you installed it.


1 Answers

To be clear, a single version of the CLR typically has multiple versions of the .NET Framework that it works with. A single version of the .NET Framework, however, only works with one specific version of the CLR. For example, CLR version 2.0 works with .NET Framework versions 2.0, 3.0, and 3.5, while CLR version 4.0 works with all of the 4.x versions of the .NET Framework (i.e. 4.0, 4.5[.x], 4.6[.x], 4.7[.x], etc). To see the chart of CLR version to Framework version relationships, see the MSDN page for .NET Framework Versions and Dependencies.

With regards to SQLCLR code, SQL Server only works with a single version of the CLR, and the specific version depends upon the version of SQL Server. SQL Server 2005, 2008, and 2008 R2 work only with CLR version 2. Since CLR version 2 only works with .NET Framework versions 2.0, 3.0, and 3.5, this means that SQL Server 2005, 2008, and 2008 R2 only work with .NET Framework versions 2.0, 3.0, and 3.5.

Of course, SQL Server 2005's CLR Integration feature (the initial version of it) was built around .NET Framework version 2.0 (as that is what was available at the time), so there are a couple of newer libraries in .NET Framework versions 3.0 and 3.5 that don't work in SQL Server 2005 without manually importing them (i.e. System.Core and System.Xml.Linq). Along those same lines, SQL Server 2012, 2014, 2016, 2017, and 2019 are statically linked to CLR version 4, which works with .NET Framework versions 4.0, 4.5[.x], 4.6[.x], and 4.7[.x].

If it makes it easier to understand, the info noted above, in chart form, is:

SQL Server version      |   CLR version   |   .NET Framework version(s)
------------------------|-----------------|----------------------------
2005                    |   2.0           |   2.0, 3.0 **, and 3.5 **
                        |                 | ** To use any functionality within
                        |                 |    System.Core or System.Xml.Linq
                        |                 |    libraries, they must be imported
                        |                 |    manually as UNSAFE.
------------------------|-----------------|----------------------------
2008 and 2008 R2        |   2.0           |   2.0, 3.0, and 3.5
------------------------|-----------------|----------------------------
2012, 2014, 2016, 2017, |   4.0           |   4.0+
and 2019, (and should   |                 |
also be Azure SQL DB    |                 |
Managed Instance)       |                 |
------------------------|-----------------|----------------------------

With regards to the information returned from both System.Environment.Version (in .NET code) and SELECT [value] FROM sys.dm_clr_properties WHERE [name] = N'version';, they are reporting the CLR version, not the .NET Framework version. So be careful not to confuse those two things reporting 2.0 or 4.0 as meaning you can only use Framework version 2.0 or 4.0.

And fortunately, due to backwards compatibility, code compiled against the CLR 2 Framework versions (2.0, 3.0, and 3.5) will run without needing to be recompiled in SQL Server 2012 and newer, even though they are on CLR version 4.

So, you generally cannot go wrong with using a Target Framework Version of 2.0, but you most certainly can use Framework versions beyond 2.0.

For a more in-depth look at developing SQLCLR code, check out the following article (and the series in general), which I wrote:

Stairway to SQLCLR Level 5: Development (Using .NET within SQL Server)

For more info on working with SQLCLR in general, please visit: SQLCLR Info

like image 81
Solomon Rutzky Avatar answered Sep 18 '22 19:09

Solomon Rutzky