SQL Server: Create Table using first row of Text File as Column names
How can I read the first row of a text file (comma separated) and use that as the f开发者_StackOverflow中文版ield 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.
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".
Have you tried to use OPENROWSET?
精彩评论