Your SlideShare is downloading. ×
CLR Stored Procedures
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

CLR Stored Procedures

816
views

Published on

Presentation I used in JAN monthly meetup on SQL Server Universe community (http://www.sqlserveruniverse.com).

Presentation I used in JAN monthly meetup on SQL Server Universe community (http://www.sqlserveruniverse.com).

Published in: Technology

1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
816
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
12
Comments
1
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  •  TRUSTWORTHY : indicate whether the instance of SQL Server trusts the database and the contents within it.
  • Transcript

    • 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. How to use (demo)
      SqlPipe
      Debug
      Send SQL query as a result
      Custom Result Sets
      Single record
      Multiple records (SendResultsStart, SendResultsRow, SendResultsEnd)
      • Connection String
      ADO.NET
    • 10. Errors When Debugging
    • 11. External Access
    • 12. External Access (demo)
    • 13. Serialization Errors
      “Cannot load dynamically generated serialization assembly”
      Add post build event
      "C:Program Files (x86)Microsoft Visual Studio 8SDKv2.0Binsgen.exe" /force "$(TargetPath)"
      More information : http://support.microsoft.com/kb/913668
    • 14. Deployment
      Deploy assembly
      SP
    • 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.
    • 18. References
      http://msdn.microsoft.com/en-us/library/ms131094.aspx - CLR Stored Procedures
    • 19. Thank you