SlideShare a Scribd company logo
1 of 19
CLR Stored Procedures HarshanaWeerasinghe http://about.me/harshana
Agenda SQL CLR CLR Stored Procedures The Need For CLR Stored Procedures Drawbacks Configuration  How to use (demo) Debugging SQL CLR DLLs External Access External Access (demo) Deployment
SQL CLR ?  Is the technology that hosts the Microsoft .NET Common Language Runtime engine within SQL Server. SQLCLR allows managed code to be hosted by, and run in, the Microsoft SQL Server environment
CLR Stored Procedures Similar to normal Stored Procedures, but code written using Microsoft .NET (C#, VB.NET or any language in .NET) Works as an MSIL assembly integrated with the SQL Engine.
The Need For CLR Stored Procedures Gives better results while executing complex logic:  Intense string operations/string manipulation Cryptography Accessing system resources File Management CLR Stored Procedures are managed code Ensures type safety Ensures memory management
The Need For CLR Stored Procedures Better code management Provides object oriented programming Encapsulation Polymorphism Inheritance Can be written using C# VB Any other language that the .NET Framework supports
Drawbacks Not convenient in all scenarios E.g. they should not be used to execute simple queries. Deployment may be difficult in some scenarios.
Configuration Enable CLR in SQL Server
How to use (demo) SqlPipe Debug Send SQL query as a result Custom Result Sets Single record Multiple records (SendResultsStart, SendResultsRow, SendResultsEnd) ,[object Object],ADO.NET
Errors When Debugging
External Access
External Access (demo)
Serialization Errors “Cannot load dynamically generated serialization assembly” Add post build event "C:rogram Files (x86)icrosoft Visual Studio 8DK2.0ingen.exe" /force "$(TargetPath)" More information : http://support.microsoft.com/kb/913668
Deployment Deploy assembly SP
Q & A What Sgen.exe does ? The XML Serializer Generator creates an XML serialization assembly for types in a specified assembly in order to improve the startup performance of a XmlSerializer when it serializes or deserializesobjects of the specified types.
Q & A What is the deference between PERMISSION_SET SAFE, EXTERNAL_ACCESS and UNSAFE ?  Code executed by an assembly with SAFE permissions cannot access external system resources such as files, the network, environment variables, or the registryand EXTERNAL_ACCESS can access. UNSAFE enables assemblies unrestricted access to resources, both within and outside an instance of SQL Server. Code running from within an UNSAFE assembly can call unmanaged code.
Q & A List down Benefits of using CLR Stored Procedures See the “The Need For CLR Stored Procedures” in presentation.
References http://msdn.microsoft.com/en-us/library/ms131094.aspx - CLR Stored Procedures
Thank you

More Related Content

What's hot

Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practices
eleksdev
 
Puppet Camp Charlotte 2015: Managing middleware with Puppet
Puppet Camp Charlotte 2015: Managing middleware with PuppetPuppet Camp Charlotte 2015: Managing middleware with Puppet
Puppet Camp Charlotte 2015: Managing middleware with Puppet
Puppet
 

What's hot (20)

OWIN and Katana Project - Not Only IIS - NoIIS
OWIN and Katana Project - Not Only IIS - NoIISOWIN and Katana Project - Not Only IIS - NoIIS
OWIN and Katana Project - Not Only IIS - NoIIS
 
ASP.NET: Present and future
ASP.NET: Present and futureASP.NET: Present and future
ASP.NET: Present and future
 
Integrating Apache Syncope with Apache CXF
Integrating Apache Syncope with Apache CXFIntegrating Apache Syncope with Apache CXF
Integrating Apache Syncope with Apache CXF
 
Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practices
 
Introduction to Integration Testing With Cypress
Introduction to Integration Testing With CypressIntroduction to Integration Testing With Cypress
Introduction to Integration Testing With Cypress
 
ASP.NET Core Demos
ASP.NET Core DemosASP.NET Core Demos
ASP.NET Core Demos
 
ASP.NET Core Demos Part 2
ASP.NET Core Demos Part 2ASP.NET Core Demos Part 2
ASP.NET Core Demos Part 2
 
Puppet Camp Charlotte 2015: Managing middleware with Puppet
Puppet Camp Charlotte 2015: Managing middleware with PuppetPuppet Camp Charlotte 2015: Managing middleware with Puppet
Puppet Camp Charlotte 2015: Managing middleware with Puppet
 
O que é esse tal de OWIN?
O que é esse tal de OWIN?O que é esse tal de OWIN?
O que é esse tal de OWIN?
 
Introduction to OWIN
Introduction to OWINIntroduction to OWIN
Introduction to OWIN
 
Node.js quick intro
Node.js quick introNode.js quick intro
Node.js quick intro
 
Power shell basics day1
Power shell basics day1Power shell basics day1
Power shell basics day1
 
Power shell basics day 3
Power shell basics day 3Power shell basics day 3
Power shell basics day 3
 
Lateral Movement with PowerShell
Lateral Movement with PowerShellLateral Movement with PowerShell
Lateral Movement with PowerShell
 
Blazor, lo sapevi che...
Blazor, lo sapevi che...Blazor, lo sapevi che...
Blazor, lo sapevi che...
 
Power shell basics day 2
Power shell basics day 2Power shell basics day 2
Power shell basics day 2
 
КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...
КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...
КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...
 
Finally, easy integration testing with Testcontainers
Finally, easy integration testing with TestcontainersFinally, easy integration testing with Testcontainers
Finally, easy integration testing with Testcontainers
 
QN Blue Lava
QN Blue LavaQN Blue Lava
QN Blue Lava
 
Cypress - Best Practices
Cypress - Best PracticesCypress - Best Practices
Cypress - Best Practices
 

Similar to CLR Stored Procedures

SQLCLR For DBAs and Developers
SQLCLR For DBAs and DevelopersSQLCLR For DBAs and Developers
SQLCLR For DBAs and Developers
webhostingguy
 
Dr. Jekyll and Mr. Hyde
Dr. Jekyll and Mr. HydeDr. Jekyll and Mr. Hyde
Dr. Jekyll and Mr. Hyde
webhostingguy
 
Creating Secure Applications
Creating Secure Applications Creating Secure Applications
Creating Secure Applications
guest879f38
 
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
webhostingguy
 
SQL Server Security - Attack
SQL Server Security - Attack SQL Server Security - Attack
SQL Server Security - Attack
webhostingguy
 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Net
webhostingguy
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Net
vidyamittal
 
.NET TECHNOLOGIES
.NET TECHNOLOGIES.NET TECHNOLOGIES
.NET TECHNOLOGIES
Prof Ansari
 
Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - English
Svetlin Nakov
 
NNUG Certification Presentation
NNUG Certification PresentationNNUG Certification Presentation
NNUG Certification Presentation
Niall Merrigan
 

Similar to CLR Stored Procedures (20)

SQL Server - CLR integration
SQL Server - CLR integrationSQL Server - CLR integration
SQL Server - CLR integration
 
SQLCLR For DBAs and Developers
SQLCLR For DBAs and DevelopersSQLCLR For DBAs and Developers
SQLCLR For DBAs and Developers
 
Dr. Jekyll and Mr. Hyde
Dr. Jekyll and Mr. HydeDr. Jekyll and Mr. Hyde
Dr. Jekyll and Mr. Hyde
 
23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqra23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqra
 
Creating Secure Applications
Creating Secure Applications Creating Secure Applications
Creating Secure Applications
 
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
 
SynapseIndia dotnet development platform overview
SynapseIndia  dotnet development platform overviewSynapseIndia  dotnet development platform overview
SynapseIndia dotnet development platform overview
 
SQL Server Security - Attack
SQL Server Security - Attack SQL Server Security - Attack
SQL Server Security - Attack
 
System verilog important
System verilog importantSystem verilog important
System verilog important
 
Day2
Day2Day2
Day2
 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Net
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Net
 
.NET TECHNOLOGIES
.NET TECHNOLOGIES.NET TECHNOLOGIES
.NET TECHNOLOGIES
 
Windows azure overview for SharePoint Pros
Windows azure overview for SharePoint Pros Windows azure overview for SharePoint Pros
Windows azure overview for SharePoint Pros
 
Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - English
 
SQLCLR Tips & Trics
SQLCLR Tips & TricsSQLCLR Tips & Trics
SQLCLR Tips & Trics
 
.Net platform an understanding
.Net platform an understanding.Net platform an understanding
.Net platform an understanding
 
NNUG Certification Presentation
NNUG Certification PresentationNNUG Certification Presentation
NNUG Certification Presentation
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - Introduction
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

CLR Stored Procedures

  • 1. CLR Stored Procedures HarshanaWeerasinghe http://about.me/harshana
  • 2. Agenda SQL CLR CLR Stored Procedures The Need For CLR Stored Procedures Drawbacks Configuration How to use (demo) Debugging SQL CLR DLLs External Access External Access (demo) Deployment
  • 3. SQL CLR ?  Is the technology that hosts the Microsoft .NET Common Language Runtime engine within SQL Server. SQLCLR allows managed code to be hosted by, and run in, the Microsoft SQL Server environment
  • 4. CLR Stored Procedures Similar to normal Stored Procedures, but code written using Microsoft .NET (C#, VB.NET or any language in .NET) Works as an MSIL assembly integrated with the SQL Engine.
  • 5. The Need For CLR Stored Procedures Gives better results while executing complex logic: Intense string operations/string manipulation Cryptography Accessing system resources File Management CLR Stored Procedures are managed code Ensures type safety Ensures memory management
  • 6. The Need For CLR Stored Procedures Better code management Provides object oriented programming Encapsulation Polymorphism Inheritance Can be written using C# VB Any other language that the .NET Framework supports
  • 7. Drawbacks Not convenient in all scenarios E.g. they should not be used to execute simple queries. Deployment may be difficult in some scenarios.
  • 8. Configuration Enable CLR in SQL Server
  • 9.
  • 13. Serialization Errors “Cannot load dynamically generated serialization assembly” Add post build event "C:rogram Files (x86)icrosoft Visual Studio 8DK2.0ingen.exe" /force "$(TargetPath)" More information : http://support.microsoft.com/kb/913668
  • 15. Q & A What Sgen.exe does ? The XML Serializer Generator creates an XML serialization assembly for types in a specified assembly in order to improve the startup performance of a XmlSerializer when it serializes or deserializesobjects of the specified types.
  • 16. Q & A What is the deference between PERMISSION_SET SAFE, EXTERNAL_ACCESS and UNSAFE ? Code executed by an assembly with SAFE permissions cannot access external system resources such as files, the network, environment variables, or the registryand EXTERNAL_ACCESS can access. UNSAFE enables assemblies unrestricted access to resources, both within and outside an instance of SQL Server. Code running from within an UNSAFE assembly can call unmanaged code.
  • 17. Q & A List down Benefits of using CLR Stored Procedures See the “The Need For CLR Stored Procedures” in presentation.

Editor's Notes

  1.  TRUSTWORTHY : indicate whether the instance of SQL Server trusts the database and the contents within it.