0

I have a sql script in which we specify path of the .csv data file contains data to be loaded in database.

The name of the data file may change so I need to generalize the script.Basically data file may contain version number which may change over time.

For example:

BULK INSERT tablename
FROM 'C:\Data\abc_1_123.csv'

Is there a way I can specify file location like

BULK INSERT tablename
FROM 'C:\Data\abc_*.csv'

which would generalize the script.

bummi
  • 27,123
  • 14
  • 62
  • 101
user458580
  • 51
  • 1
  • 2
  • 1
    have you tried `%` instead of `*`? That's often used as the wildcard character in SQL Server – Dan Oct 04 '13 at 07:34
  • you can save csv file path in sql variable and excute dynamic sql – Jagz W Oct 04 '13 at 08:52
  • Can you please show an example of executing above task in dynamic sql. Basically C:\Data\abc_*.csv would return just one file. Can I do something like this. @filename = 'C:\Data\abc_*.csv'; BULK INSERT tablename FROM '''+@filename+''' – user458580 Oct 04 '13 at 09:48

0 Answers0