SQL Server – What is the need of Common Language Runtime (CLR) in SQL Server?

Hey Folks,

Do you really know, why there’s a need of Common Language Runtime (CLR) required instead of having T-SQL? Well I have some keynotes here:

  • Transact-SQL is specifically designed for direct data access and manipulation in the database.
  • As Transact-SQL excels at data access and management, it does not have programming constructs that make data manipulation and computation easy. Like they does not support arrays, collections, for-each loops, bit shifting, or classes.
  • T-SQL is great for database code, but writing procedural code in T-SQL has always been difficult.
  • So in comes the Microsoft SQL Server 2005 significantly enhances the database programming model by hosting the Microsoft .NET Framework 2.0 Common Language Runtime (CLR).
  • The common language runtime (CLR) is the heart of the Microsoft .NET Framework and provides the execution environment for all .NET Framework code.
  • This enables developers to write procedures, triggers, and functions in any of the CLR languages, particularly Microsoft Visual C# .NET, Microsoft Visual Basic .NET, and Microsoft Visual C++.
  • The code that runs within the CLR is referred to as managed code.
  • Managed code is better suited than Transact-SQL for calculations and complicated execution logic, and features extensive support for many complex tasks, including string handling and regular expressions.
  • One of the benefits of managed code is type safety, or the assurance that code accesses types only in well-defined, permissible ways. Before managed code is executed, the CLR verifies that the code is safe.
  • With the functionality found in the .NET Framework Library, you also have the access to thousands of pre-built classes and routines.
  • By default, the common language runtime is disabled in SQL Server and must be specifically enabled using a T-SQL SET command.

Hope you like this post.

   

 

Regards

Piyush Bajaj

Like us on FaceBook Follow us on Twitter | Join the fastest growing SQL Server group on FaceBook

Follow me on Twitter  |  Follow me on FaceBook

   

About Piyush Bajaj

I am very passionate about SQL Server. I also did certification on MCSA – SQL Server 2012, Querying and Administering; MCTS – SQL Server 2008, Database Development; and MCTS – SQL Server 2005, Implementation & Maintenance, which helped me to get more knowledge and interest on this field.Please feel free to drop me any question online or offline, I will try to give you the best possible answer from my side.Right now I am working as a SQL Server developer in TCS. I have an experience of just 2.6 years, well I can only say that “If you have an interest and passion, experience might become a very small thing”.

View all posts by Piyush Bajaj →

Leave a Reply

Your email address will not be published.