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.
| Author |
Topic |
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2012-06-18 : 09:35:10
|
| Dear All,I would like to insert a .csv file on daily basis.This file will be created daily with a dynamic file name.I have a below query its work perfectly but how to modify to set the file name to be dynamic.CREATE TABLE [dbo].[IData]( [supID] [varchar](50) NULL, [permutationCode] [varchar](50) NULL, [TypeCode] [varchar](50) NULL, [RegionCode] [varchar](50) NULL, [duration] [int] NULL, ) ON [PRIMARY]GOBULKINSERT [dbo].[IData]FROM 'C:\test.txt'WITH(FIRSTROW = 2, FIELDTERMINATOR = '\t',ROWTERMINATOR = '\n')GOAny help will be highly appreciated.ThanksRegards,SG |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-18 : 11:55:10
|
| declare @sql varchar(4000)select @sql = 'BULKINSERT [dbo].[IData]FROM ''' + @filename + '''WITH(FIRSTROW = 2, FIELDTERMINATOR = ''\t'',ROWTERMINATOR = ''\n'')'exec (@sql)==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-18 : 11:59:39
|
| You can implement similar logic using SSIS also where file generated can have dynamic name like including current date value in it.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|