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

    « SSRS Properties - Image SourceSSRS Properties - CanGrow and CanShrink »
    comments

    Starting with SQL Server 2005 xp_cmdshell is turned off by default as a security measure. You have to explicitly enable xp_cmdshell it. If you have to move files around on a SQL Server box there are probably better ways than using xp_cmdshell, you can use SSIS, powershell, plain old DOS. But old habits are difficult to break and maybe you have ton of legacy code. Someone asked how to supress output from xp_cmdshell when moving a file

    I you move a file with xp_cmdshell, you will get the following output
    output
    1 file(s) moved.
    NULL

    If I want to move a file from c:\temp to c:\temp\old, I would execute the following

    1. xp_cmdshell 'move c:\temp\bla.txtc:\temp\old\bla.txt'

    Here is what it looks like in SSMS

    As you can see you get a resultset, in order to surpress that, you can add no_output to the xp_cmdshell call, no_output is an optional parameter, specifying that no output should be returned to the client.

    Here is what the command looks like

    1. xp_cmdshell 'move c:\temp\bla.txt c:\temp\old\bla.txt',no_output

    Executing the command like that will not return a resultset anymore

    About the Author

    User bio imageDenis has been working with SQL Server since version 6.5. Although he worked as an ASP/JSP/ColdFusion developer before the dot com bust, he has been working exclusively as a database developer/architect since 2002. In addition to English, Denis is also fluent in Croatian and Dutch, but he can curse in many other languages and dialects (just ask the SQL optimizer) He lives in Princeton, NJ with his wife and three kids.
    Social SitingsTwitterFacebookLinkedInHomePageFlickrLTD RSS Feed
    1060 views
    InstapaperVote on HN

    No feedback yet

    Leave a comment


    Your email address will not be revealed on this site.

    To mislead the spambots.

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