• This is beginning to sound like the "Why do we need Cursors?" debate. Just like cursors, I'd be highly sceptical why anyone would need to leverage xp_cmdshell in a stored procedure. Still it's a useful tool for ad-hoc sysadmin tasks, like when the sysadmin doesn't have a login on the host operating system.

    Case in point: Just this morning I was asked to rename a database (AbcCorp -> AbcCorpOld) in the DEV and QA environments and then create a new database with the same name (AbcCorp) and empty tables. To keep the physical file names consistent with the logical database name, I also had to detach, re-name files, and then re-attach the old database. However, to rename the files, I had to use xp_cmdshell, because I don't have a local login on the host operating server.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho