开发者

SQL Server: Create Table using first row of Text File as Column names

开发者 https://www.devze.com 2022-12-16 07:33 出处:网络
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?

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消