Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Verify File Name

Author  Topic 

ConBran
Starting Member

5 Posts

Posted - 2005-01-12 : 08:11:20
I hope that this can be quickly answered and implemented!! I have a package set up that loops through the contents of a folder and imports them to my database. I was just wondering if it was possible to verify the format of the file name. All my file names are in the format:

W##IDFmmyyyy.csv

I would like to verify that the values for W##, mm, yyyy are valid values and that 'IDF' is present.

Is there any way to do this easily?

Thanks in advance

Connor

X002548
Not Just a Number

15586 Posts

Posted - 2005-01-12 : 16:34:55
[code]
Insert Into Ledger_Folder exec master..xp_cmdshell 'Dir d:\Data\Tax\SmartStreamExtracts\*.*'
Delete From Ledger_Folder_Parsed

Insert Into Ledger_Folder_Parsed (Create_Time, File_Size, File_Name )
Select Convert(datetime,Substring(dir_output,1,8)
+ ' '
+ (Substring(dir_output,11,5)
+ Case When Substring(dir_output,16,1) = 'a' Then ' AM' Else ' PM' End)) As Create_Time
, Convert(Int,LTrim(RTrim(Replace(Substring(dir_output,17,22),',','')))) As File_Size
, Substring(dir_output,40,(Len(dir_output)-39)) As File_Name
From Ledger_Folder
Where Substring(dir_output,1,1) <> ' '
And (Substring(dir_output,1,1) <> ' '
And Substring(dir_output,25,5) <> '<DIR>')
[/code]


Brett

8-)
Go to Top of Page
   

- Advertisement -