xp_cmdshell

March 14th, 2007 by Mr.M | No Comments »

At my old job, the developers would use xp_cmdshell but I never cared for or looked at it until now … it is pretty damn useful:

declare @sourceDir varchar(500), @archiveDir(500)
exec xp_cmdshell = 'move /Y ' + @sourceDir + '\*.dat ' + @archiveDir

And you can do many things with the output, parse it for certain files, dump it into a table, cursor the table, do some historical data gathering, etc …

Leave a Reply

You must be logged in to post a comment.