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 2005 Forums
 Transact-SQL (2005)
 Bulk Insert

Author  Topic 

descsh
Starting Member

5 Posts

Posted - 2008-05-15 : 02:47:23
Using the bulk insert command in MS SQL 2005, how can I insert data from a text file which filename is based on date. for example, today the file name is abc_20050512.txt. Tomorrow the file name will be abc_20050513.txt. actually I am trying to use the buld insert command to read in the file daily without manual changing the file name everyday.

I had the @dp_acctfile declared and stored the file name in this variable. But it didn't work. It gave me the error message "Incorrect syntax near '@dp_acctfile'

Bulk insert development.develop.Account from @dp_acctfile

how can I automate the insertion? any other way to do so?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-15 : 03:01:42
I think you can do this by means of SSIS package. Just make a vraibale to hold filename inside package, append it to currentdate of package run and then use file source and OLEDB destination tasks for transfering file data. You can create job also to call this dts daily so that transfer happens automatically.
Go to Top of Page
   

- Advertisement -