Wednesday, May 13, 2015
Monday, May 11, 2015
Knowledge : About "SQL CLR" (Common Language Runtime)
About "SQL CLR":
- The Common Language Runtime (CLR) is the core of the Microsoft .NET Framework, providing the execution environment for all .NET code.
- CLR has been embedded with SQL Server from start of SQL Server 2005, so this is also called as "SQL CLR".
- The main goal of SQL CLR is to to provide better Reliability, Scalability, Security & Performance.
- "SQL CLR" supports Stored Procedures, Triggers, User-defined Functions, Table-valued Functions, User-defined aggregates, User-defined Types.
- When a user requests "SQL CLR" object for the first time the SQL will load .Net execution engine mscoree.dll into memory. Then the CLR makes request to "SQLOS" (SQL Operating System) for new threads and memory allocation.
- SQLOS has all control over the SQL CLR requests / threads created. SQLOS can create new threads and also can suspend threads which idle for long time to release resources.
- Below is the high level architecture of "SQL CLR",
Properties of "T-SQL" vs "SQL CLR":
Properties | Transact SQL | SQL CLR |
---|---|---|
Code Execution | Compiled | Interpreted |
Code Model | Set Based | Procedural Based |
Access to subset of the .NETFramework Base Class Libraries (BCL) | No |
Yes |
SQL Server Access | Direct Access | In-Process Provider |
Support Complex Types | No | Yes |
Parameters Support | Yes | Yes |
When To Use "T-SQL" & "SQL CLR":
- For all basic CRUD (Create, Update, Read & Delete) operations it is highly recommended to use T-SQL. For all other performance intensive operations which use cursors, string/text manipulations, accessing external resources like acessing text/binary files etc; we should use SQL CLR.
Subscribe to:
Posts (Atom)