Examples

Current Articles | Categories | Search

Using the SQL CLR to pass Files "Through" your Firewall
By Wayne Hamilton @ 9:39 AM :: 3351 Views :: 0 Comments

In some corporate environments the only access web servers in a DMZ have to the internal network is their connection to SQL Server and it's data.  This SQL CLR example provides an option to put that connection to work serving up other files through the Firewall without having to change any external security.

Read More..
Replacing Unsafe System.Web HttpUtility.HtmlDecode with SAFE SQL CLR User-Defined Function
By Jonathan Kehayias @ 10:30 AM :: 7560 Views :: 1 Comments

I have seen a number of posts on various forums regarding issues with loading the System.Web assembly as Unsafe in SQL Server so that the HttpUtility.HtmlEncode/HtmlDecode method can be used to encode/decode an input for usage. The following function can be cataloged as SAFE in SQL Server and does exactly the same things that the Method in System.Web does for the HtmlDecode.

Read More..
Replacing Unsafe System.Web HttpUtility.HtmlEncode with SAFE SQL CLR User-Defined Function
By Jonathan Kehayias @ 8:13 AM :: 4761 Views :: 0 Comments

I have seen a number of posts on various forums regarding issues with loading the System.Web assembly as Unsafe in SQL Server so that the HttpUtility.HtmlEncode/HtmlDecode method can be used to encode/decode an input for usage. The following function can be cataloged as SAFE in SQL Server and does exactly the same things that the Method in System.Web does for the HtmlDecode.

Read More..
BULK load multiple files
By David Dye @ 5:18 PM :: 3116 Views :: 0 Comments

The ability to insert a file into a VARBINARY(MAX) or VARCHAR(MAX) column using OPENROWSET is an awesome tool.  The obstacle comes when you wish to insert all or specific files from a foler into sql.  To do this you can use the System.IO namespace and utilizing directory and file objects you can iterate through all, or selected files in a path specified in the above clr stored procedure.  After deploying this proc I would recommend adding a default value to the extn input parameter of '*.*', which indicates all files.

Read More..
Exporting to a Fixed Width File
By Wayne Hamilton @ 8:35 AM :: 4157 Views :: 0 Comments

For a project I was working on, users wanted to be able Trigger exports from SQL to a Mainframe application that used a Fixed Column Width format for the data transfer.  Since the Mainframe expects the same file name each time, the users wanted a way to maintain a history of the files that were exported across.  I tried to set up the parameters so that it could be reused without having to rewrite it each time.

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