Creating a SQL Server table from a C# datatable

前端 未结 9 1076
死守一世寂寞
死守一世寂寞 2020-12-01 01:38

I have a DataTable that I manually created and loaded with data using C#.

What would be the most efficient way to create a table in SQL Server 2005 that uses the col

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 02:10

    How efficient do you need? I would probably write my own TSQL (based on the DataTable's columns) to create the table + columns, but to fill it you have a choice; if you have a moderate number of rows, a SqlDataAdapter should be fine. If you have lots of data, then SqlBulkCopy accepts a DataTable and table name...

提交回复
热议问题