Often we try to copy the files from sql server tables and we end up renaming the copied file names manually.
Here is simple sql server statement, where it pull the message archive location and name of the file will be with some GUID and you want to name with PO number column , use this simple select statement
select ‘copy ‘+MessageArchiveLocation +’,’+’"’+PONumber+’.xml’+’"’ from Ordertransactions (nolock) where PONumber in
order by 1 desc
you will get the results, then copy them to batch file and run it.