| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Whenever you search in PBworks or on the Web, Dokkio Sidebar (from the makers of PBworks) will run the same search in your Drive, Dropbox, OneDrive, Gmail, Slack, and browsed web pages. Now you can find what you're looking for wherever it lives. Try Dokkio Sidebar for free.

View
 

SQL Server

Page history last edited by Corey Alix 14 years, 6 months ago

SQL Server .NET Integration

 

PERFORMANCE:

CLR functions that are computing-intensive and that do not perform data access are better written in managed code

Managed code can significantly outperform cursor-based aggregation

Managed STVFs perform better than comparable extended stored procedure implementations

 

CREATE:

Imports System

Imports System.Data

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Imports Microsoft.SqlServer.Server

 

Partial Public Class StoredProcedures

    <Microsoft.SqlServer.Server.SqlProcedure()> _

    Public Shared Sub  StoredProcedure1 ()

        SqlContext.Pipe.Send(System.DateTime.Today.ToString())

    End Sub

End Class

 

DEPLOY:

CREATE ASSEMBLY assembly_name

[ AUTHORIZATION owner_name ]

FROM { <client_assembly_specifier> | <assembly_bits> [ ,...n ] }

[ WITH PERMISSION_SET = { SAFE | EXTERNAL_ACCESS | UNSAFE } ]

[ ; ]

 

INVOKE:

EXEC [dbo].StoredProcedure1

GO

 

ERROR: 

Execution of user code in the .NET Framework is disabled. Enable "clr enabled" configuration option.

 

RESOLUTION:

sp_configure 'clr enabled', 1

go

reconfigure

go

 

References:

TUTORIAL - http://www.sqlteam.com/article/writing-clr-stored-procedures-in-charp-introduction-to-charp-part-1

CREATE ASSEMBLY - http://msdn.microsoft.com/en-us/library/ms189524.aspx

CLR PERFORMANCE - http://msdn.microsoft.com/en-us/library/ms131075.aspx

 

 

Comments (0)

You don't have permission to comment on this page.