Examples

Current Articles | Categories | Search

Locate recently created/modified file
By David Dye @ 4:20 AM :: 285 Views :: 0 Comments

I have had numerous occassions where I needed to find the most recently modified or created file from a specific path and return this value along with the full path.  The below clr function accepts three parameters:

  1. File path,
  2. Criteria of "created" or "modified", specifies the criteria of the most recent date to search for
  3. File extension, a value of  "*" will search all file extensions.

This code uses the System.IO namespace and requires access the the file system so it is necessary to deploy the assembly with external access permission level. 

It should be noted that the return value is set to SqlString.  If a file not matching the criteria is not located or the path is invalid then the string value of"NULL' is returned.  This is a string value and not a sql NULL value.  

Read More..
SqlBulkCopy Sample Framework
By Jonathan Kehayias @ 8:52 PM :: 371 Views :: 0 Comments

This example provides a framework for the SqlBulkCopy class and its implementation in SQL CLR.

Read More..
Generic Regular Expression Function
By Jonathan Kehayias @ 1:18 AM :: 261 Views :: 2 Comments

This example covers creating a generic user defined function to allow the use of regular expressions in SQL Server for pattern matching.  This can then replace the pattern matching in tsql.

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.6718621 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.