views:

86

answers:

2

Hello all,

How can I read the first row of a text file (comma separated) and use that as the field names of a new table I want to create in SQL Server?

The field names can all be varchar.

Thanks all

UPDTAE

Please note I would like to do this using T-SQL or any other way (sqlcmd etc). I do not want to use the wizard.

+3  A: 

Use the import data wizard (right-click database/Tasks/Import Data...). Select flat file as your Data Source, and check the checkbox "Column names in the first data row".

RedFilter
I want to do this in an automated way, sorry I should of stated this.
Abs
And since you can save this a sn SSIS package and schedule it as a job, it is the best way to get an automated process.
HLGEM
Some of my clients may not be using SSIS and I need this coupled with the rest of my script which exports data back out as a text file.
Abs
+1  A: 

Have you tried to use OPENROWSET?

Jose Chama