This a best method to invoke command prompt through a stored Procedure
Syntax
EXEC xp_cmdshell 'Command as parameter'
To execute a command and to return an output use this method
To execute a command and not to return an output use the following method
Syntax
EXEC xp_cmdshell 'Command as parameter'
To execute a command and to return an output use this method
EXEC xp_cmdshell 'dir *.exe'
EXEC xp_cmdshell 'dir *.exe', NO_OUTPUT
Example:----
DECLARE @result int
EXEC @result = xp_cmdshell 'dir *.exe'
IF (@result = 0)
PRINT 'Success'
ELSE
PRINT 'Failure'
No comments:
Post a Comment