Examples

Current Articles | Categories | Search

Using a CLR TVF to SELECT Job Execution Status
By Jonathan Kehayias @ 6:57 PM :: 247 Views :: 0 Comments

Trying to determine the status of a job in TSQL can be difficult if you are trying to do it through automated code.  You can't use a tempory table to store the results of sp_help_job since it already does this, and nested inserts of executing procedures is not allowed.  To get around this limitation, you can use a CLR TVF to return the output of sp_help_job as a table.

Read More..
Using a CLR TVF to SELECT from the SQL Error Log
By Jonathan Kehayias @ 6:39 PM :: 137 Views :: 0 Comments

Monitoring ErrorLogs in SQL Server can be done a number of ways, but if you want to scan the contents in SQL and use filters to SELECT specific events from the Error Log in TSQL, it has traditionally required creating a temporary table to hold the results of xp_readerrorlog and then running your selects against this temp table.  This method requires a lot of code, and isn't a fast way to pull data on the fly.  Now with SQL CLR and Table Valued Functions it is simple to create a permanent solution to this problem.

Read More..
Parse hyperlinks from a file
By David Dye @ 8:09 AM :: 120 Views :: 0 Comments

One of the requirements of a project we implemented was to parse all the hyperlinks from documents and insert them into a table.  This clr stored procedure uses regex to parse all hyperlinks and insert each into into a table and column specified in the procedure.  Since the procedure accesses the file system it is necessary to set the permission to External.  There is extra code that I used to debug sending the statements to the message tab.  There are comments in these areas, but I left them in to make it easier to become familiar with the code and change as needed.

 

Read More..
Export xml query results to file
By David Dye @ 8:24 AM :: 248 Views :: 0 Comments

This clr procedure accepts a file path and a FOR XML query and saves the xml results to the specified file.

Read More..
Write to event log
By David Dye @ 5:58 AM :: 164 Views :: 0 Comments

The following example uses the clr to write to the event log.

Read More..
Previous Page | Next Page

Survey

Which of the following CLR objects are you currently using in SQL Server?




Submit Survey  View Results

Links

  Search

What's New

 Subscribe in a reader

Vote For It - Server Side Compiles in SQL CLR by Jonathan Kehayias

Greg Low a SQL Server MVP, has submitted a very compelling Connect item 265266, Add server-side compilation ability to SQL CLR which aims to remove the requirement to develop SQLCLR assemblies external to SQL Server.  Read about this suggestion here, and vote for it by visiting the Connect site to let Microsoft know you think it is important.

Using CLR Impersonation to Access Resources Outside of SQL Server by Jonathan Kehayias

Traditionally if you had a need to access a file or other resource outside of SQL Server, the SQL Server service account was required to have appropriate file system access to the folder or path containing the file.  With CLR integration, this is no longer an absolute requirement.  Identity Impersonation will allow you to implicitly or explicitly change the execution context inside of a SQLCLR Function, Procedure, or Trigger. 

Using an Application Configuration (app.config/web.config) File in SQL Server CLR Integration by Jonathan Kehayias

A common part of programming in .NET is to use an configuration file to store configuration information in an easily modifiable location.  The app.config or web.config file is an invaluable inclusion in most .NET projects and developers may need to maintain this functionality as a part of logic sharing between objects in the database and the application as well.  This article will demonstrate how to configure your SQLCLR project to use Configuration Files in SQL.

Recent Examples


Copyright 2007 by SQLCLR.net Terms Of Use Privacy Statement
Website graphics provided by Matt Green Designs
Page generated in 0.3593681 seconds.

All information and example code on this site is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from its use.

This site is in no way affiliated with Microsoft. Unless specifically stated otherwise, nothing should be construed to represent the official positions or opinions of Microsoft and/or its Employees.