My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

Accessing Cmd Prompt from Stored Procedures xp_cmdshell

Tuesday, 7 June 2011

DECLARE @CmdToExecute varchar='dir' -- displays directories

DECLARE @returncode int 
EXEC @returncode = xp_cmdshell @CmdToExecute ,no_output

SELECT @returncode -- says whether the procedure runs successfully or not 0 denote success and 1 denotes failure
no_output -- denotes that the xp_cmdshell must not return the output or return value for the executed command

No comments:

Post a Comment

 

Blogger news

Blogroll

Most Reading

8.6/10