xp_cmdshell in sql server - fire-and-forget or wait-for-reply?

1k views Asked by At

When I use xp_cmdshell to zip files or hash files on a server in a stored procedure with a nex following T-sql statement to write a datetime into a log table, is this datetime after the zip cmd or hash cmd has finished on the server (wait for reply), or is it just after sending the cmd's to the server (fire-and-forget)?

1

There are 1 answers

0
Christian.K On BEST ANSWER

xp_cmdshell waits for the end of the executed command.

Note "xp_cmdshell operates synchronously" from the documentation.

Note that this also makes sense in other ways, since you get the result of the executed command "Any output is returned as rows of text.".