grotesmurf2
asked on
xp_cmdshell with variable
this is my script:
BEGIN
DECLARE @ret int
DECLARE @instr sysname
SET @instr='dir'
EXEC @ret = xp_cmdshell @instr
UPDATE dirresults SET result=@ret WHERE id=20
END
the problem is, result always stays empty (even if i change my instruction to something that doesn't exist)
my questions:
a)how can I get the result (0 or 1)?
b) how can I get the result of the dir command (e.g. the directory listing)?
BEGIN
DECLARE @ret int
DECLARE @instr sysname
SET @instr='dir'
EXEC @ret = xp_cmdshell @instr
UPDATE dirresults SET result=@ret WHERE id=20
END
the problem is, result always stays empty (even if i change my instruction to something that doesn't exist)
my questions:
a)how can I get the result (0 or 1)?
b) how can I get the result of the dir command (e.g. the directory listing)?
? why have you declared your parameter as a sysname as opposed to varchar ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
thank you all...
it must be an authority issue I guess. strange I don't get 0 or 1 as output, but just an empty string... sigh...
it must be an authority issue I guess. strange I don't get 0 or 1 as output, but just an empty string... sigh...