Want Copy Files From Sql Result as you want


Hi All,

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

(‘12344′,’112112′,’11231232’)

order by 1 desc

you will get the results, then copy them to batch file and run it.

Regards,

Chaitanya

Leave a comment

Design a site like this with WordPress.com
Get started