Use SqlConnection.GetSchema to get Tables Only (No Views)

后端 未结 2 912
难免孤独
难免孤独 2020-12-19 15:31

When I use

SqlConnection.GetSchema(\"Tables\");

it returns all the tables AND views for the target database.

Is there any way to j

相关标签:
2条回答
  • 2020-12-19 15:51

    According to this article, the returned data table has a column table_type, which tells you whether it's a VIEW or a BASE TABLE.
    Use that column to filter out the views on your C# end.

    0 讨论(0)
  • 2020-12-19 16:04

    Here is the complete syntax

    DataTable table = connection.GetSchema("Tables", new string[] { null, null, null, "BASE TABLE" });
    
    0 讨论(0)
提交回复
热议问题