I have a text file that is dumped to a network drive every morning at 1:00am. I then manually run the following code to pick up the new file and bring it into my database on SQL. I know this can be automated with a SSIS package, however, since the file name has the date in it, the name is not consistent from day to day.
How can I tell the SSIS package to pull in the most recent file available or today's file??
-- delete the contents of table PRE_BO
truncate table PRD_BO
-- drop the index on table PRE_BO to allow smooth data load
/****** Object: Index [SALES_ORD_ITEM] Script Date: 09/28/2010 11:00:35 ******/
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[PRD_BO]') AND name = N'SALES_ORD_ITEM')
DROP INDEX [SALES_ORD_ITEM] ON [dbo].[PRD_BO] WITH ( ONLINE = OFF )
-- import the data from the PRE backorder file on STLFTP01 into the PRE_BO table on SQL
BULK INSERT PRD_BO
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
-- index table PRE_BO for better performance
/****** Object: Index [item loc] Script Date: 09/27/2010 13:40:48 ******/
CREATE UNIQUE CLUSTERED INDEX [SALES_ORD_ITEM] ON [dbo].[PRD_BO]
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]