Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « Watch all the Tech·Ed North America 2011 SQL Server videosSeparation of Duties Framework Enhancements - Ask & You May Receive »
    comments

    Today’s tip is a short but powerful one.  On many occasions a DBA is forced to deal with files in some way.  It may be the need to download and move a file (or folder) around in order to prepare for importing the contents into a database or simply maintain the contents or auditing levels of them. 


    Working with files through SQL Server is more difficult than your everyday select of data from a database.  SQL Server is made to stay within the walls it has built.  This means we have to use other methods in order to accomplish what we need to do with file and folders. 

    Jason Strate (Blog | Twitter) had an idea of putting together one method that I have also used over the years – SQLCLR File System Helper.  SQLCLR provides a path for a DBA and Developer to external resources that once was extremely hard to access from within a database.  With SQLCLR we’ve been given the power of writing .NET code and placing and executing it directly within our databases.  Now this can be dangerous given the nature of the resource utilization when it comes to .NET.  However, done with planning and thought beforehand, using SQLCLR can be extremely valuable.

      Jason and I have put together a set of procedures and functions that are most common in respect to file and folder operations. 

      Utility.DirectoryCreate

      Utility.DirectoryDelete

      Utility.DirectoryDeleteContents

      Utility.DirectoryList

      Utility.DirectoryMoveTo

      Utility.DirectorySize

      Utility.FileCopy

      Utility.FileCreate

      Utility.FileDelete

      Utility.FileMove

      Utility.FileRename

      Utility.FileSearch

      Utility.FileSearchInternal

    The set of procedures and functions that are available cover a wide range of needs when you are working with files and folders.  Some of these procedures are used daily on my own scheduled tasks and very beneficial in making those schedules tasks run smooth and clean. 

    Take a look at your own SQL Server tasks that are running either on a schedule or manually and see how these methods can help you in making them more efficient. 

    As always with Codeplex items, leave us feedback on the project so Jason and I can continue on making it better and more robust.

    About the Author

    Ted Krueger is a SQL Server MVP and has been working in development and database administration for 13+ years. Specialties range from High Availability and Disaster / Recovery setup and testing methods down to custom assembly development for SQL Server Reporting Services. Ted blogs and is also one of the founders of LessThanDot.com technology community. Some of the articles focused on are Backup / Recovery, Security, SSIS and working on SQL Server and using all of the SQL Server features available to create stable and scalable database services. @onpnt
    Social SitingsTwitterLinkedInLTD RSS Feed
    590 views
    Instapaper

    2 comments

    Comment from: Justin Dearing [Visitor] · http://www.justaprogrammer.net
    Justin Dearing I find the concept intriguing. However, I'd be concerned about the security implications of this. You open up more possibilities for damage if someone finds an injection path to your db.
    05/17/11 @ 10:57
    Comment from: PP [Visitor]
    PP Thank you so very much!!! I was completely lost and now I found your article and my Brain is happy again :)
    PP
    06/28/11 @ 13:33

    Leave a comment


    Your email address will not be revealed on this site.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)