Examples

Current Articles | Categories | Search

Using the SQL CLR to pass Files "Through" your Firewall
By Wayne Hamilton @ 9:39 AM :: 177 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 :: 259 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..
Replacing Unsafe System.Web HttpUtility.HtmlEncode with SAFE SQL CLR User-Defined Function
By Jonathan Kehayias @ 8:13 AM :: 186 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 :: 167 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 :: 326 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

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