By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,738 Members | 1,730 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,738 IT Pros & Developers. It's quick & easy.

Incrementing Filename when saved

benchpolo
100+
P: 142
Filename: 20080806CLM0001.txt

Legend:
YYYYMMDDCLM9999
YYYY = four digit year
MM = two digit month
DD = two digit day
CLM = static for Claim MR
9999 = four digit sequence number (this will keep it unique in case you sent two in a day)

Using master.dbo.xp_cmdshell copy how can I incrementaly save the above filename (20080806CLM0001.txt then 20080806CLM0002.txt then 20080806CLM0003.txt)

Thanks.
Aug 6 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
You have to create a loop that will be used as your sequence. Inside the loop, you do a file check if existing and handle it accordingly. Once the filename you derived (from your sequence) is now unique, you can now save it.

All this would mean the xp_cmdshell is inside your loop.

-- CK
Aug 7 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.