![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I have a query regarding customization of data transformation using DTS. I have created a table in SQL Server 2000, in which data have to be imported from an excel file. I have a folder containing number of excel files. The problem is that, i have to import only that file which has recently been created/modified. DTS will trigger the import every half an hour and take the latest created/modified file and copy all the contents into the same table each time. Can you please suggest me how it can be done. Your response will highly be appreciated. Thanks & Regards, Pratyush Kumar. |
#3
| |||
| |||
|
|
-----Original Message----- Loop through the files using the FSO (File System Object) Create a variable to hold file names Grab the .DateLastModified and compare against the current variable replacing as needs be. Another way to do this is to archive your files once you've finished with them and you latest file will be the only one in the directory -- ---------------------------- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.allisonmitchell.com - Expert SQL Server Consultancy. www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "Pratyush Kumar" <pratyushk (AT) ggn (DOT) hcltech.com> wrote in message news:1bda01c3ff5b$4dd4e2d0$a601280a (AT) phx (DOT) gbl... Hi, I have a query regarding customization of data transformation using DTS. I have created a table in SQL Server 2000, in which data have to be imported from an excel file. I have a folder containing number of excel files. The problem is that, i have to import only that file which has recently been created/modified. DTS will trigger the import every half an hour and take the latest created/modified file and copy all the contents into the same table each time. Can you please suggest me how it can be done. Your response will highly be appreciated. Thanks & Regards, Pratyush Kumar. . |
#4
| |||
| |||
|
|
Hi Allan, Thanks for the quick response. As you suggested, i am trying to implement the following code - '************************************************* ********* ************ ' Visual Basic ActiveX Script '************************************************* ********* ************** Function Main() Dim lobjFileObject Dim lobjFolder Dim lobjFiles Dim ldtLastModiefied set lobjFileObject = CreateObject ("Scripting.FileSystemObject") Set lobjFolder = lobjFileObject.GetFolder("\\odc- ashish\Code") Set lobjFiles = lobjFolder.Files For Each File In lobjFiles ldtLastModiefied = FileDateTime("\\odc-ashish\Code\" & File.Name) If DateValue(ldtLastModiefied) >= DateValue(Now) Then 'create new connection to source Excel file 'Create new connection to table in SQL Server 'Dump data from source file into table End If Next Main = DTSTaskExecResult_Success End Function Is this correct? Regards Pratyush -----Original Message----- Loop through the files using the FSO (File System Object) Create a variable to hold file names Grab the .DateLastModified and compare against the current variable replacing as needs be. Another way to do this is to archive your files once you've finished with them and you latest file will be the only one in the directory -- ---------------------------- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.allisonmitchell.com - Expert SQL Server Consultancy. www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "Pratyush Kumar" <pratyushk (AT) ggn (DOT) hcltech.com> wrote in message news:1bda01c3ff5b$4dd4e2d0$a601280a (AT) phx (DOT) gbl... Hi, I have a query regarding customization of data transformation using DTS. I have created a table in SQL Server 2000, in which data have to be imported from an excel file. I have a folder containing number of excel files. The problem is that, i have to import only that file which has recently been created/modified. DTS will trigger the import every half an hour and take the latest created/modified file and copy all the contents into the same table each time. Can you please suggest me how it can be done. Your response will highly be appreciated. Thanks & Regards, Pratyush Kumar. . |
![]() |
| Thread Tools | |
| Display Modes | |
| |