I think I've figured out how to change file names using the exec master..xp_cmdshell function within a T-SQL statement. Now, if I have the following select statement, I can generate all the individual command lines needed to change all the files in a particular folder. However, now I need to see if there is a way to RUN each statement generated by my SELECT statement in an execute SQL task.
Here's the SELECT statement that generates the commands:
SELECT 'exec master..xp_cmdshell '+ CHAR(39) + 'ren ' + CHAR(34) + 'folderlocation' + table.unconvertedfile + CHAR(34) + ' ' + table.ordernumber + '.pdf' + CHAR(39) FROM table WHERE unconvertedfile IS NOT NULL
Any ideas on how I can store the resulting select statements into a variable or something and then run each of the statements as T-SQL statements?
Thanks in advance.