Examples

Current Articles | Categories | Search

Locate recently created/modified file
By David Dye @ 4:20 AM :: 2145 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 :: 2905 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 :: 1489 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

Q&A with Adam Machanic - Who's Afraid of SQLCLR by Jonathan Kehayias

You could almost hear the gasps of horror when Microsoft integrated the .NET Common Language Runtime (CLR) into SQL Server 2005. Run C# or VB.NET code inside SQL Server? For many database developers and administrators, it was like an alien had just burst through SQL Server’s midsection.

But SQL Server MVP Adam Machanic says that more and more developers and DBAs are discovering that far from destroying SQL Server performance and security, SQLCLR is actually a powerful ally in solving complex business and technical problems.

Read More on the PASS website..

SQLCLR String Splitting Part 2: Even Faster, Even More Scalable by Site Administrator

SQL Server MVP Adam Machanic shows a new way of parsing strings in SQL Server using SQLCLR that outperforms all conventional TSQL methods, as well as the most common SQLCLR implemenations, using a custom split function that allows streaming of the results.

Trading in xp_cmdshell for SQLCLR (Part 1) - List Directory Contents by Jonathan Kehayias

Learn how to use SQLCLR to get file system information instead of using xp_cmdshell on your SQL Servers.

Recent Examples


Copyright 2007 by SQLCLR.net Terms Of Use Privacy Statement
Website graphics provided by Matt Green Designs
Page generated in 0.2964019 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.