Need to get empty datatable in .net with database table schema

前端 未结 10 829
闹比i
闹比i 2021-02-07 04:40

What is the best way to create an Empty DataTable object with the schema of a sql server table?

10条回答
  •  借酒劲吻你
    2021-02-07 05:25

    A statement I think is worth mentioning is SET FMTONLY:

    SET FMTONLY ON;
    SELECT * FROM SomeTable
    SET FMTONLY OFF;
    

    No rows are processed or sent to the client because of the request when SET FMTONLY is turned ON.

    The reason this can be handy is because you can supply any query/stored procedure and return just the metadata of the resultset.

提交回复
热议问题