这是我的代码:
Server server = new Server(new ServerConnection(con));
server.ConnectionContext.Connect();
foreach (Table table in server.Databases[sqlDatabase].Tables)
{
if (table <is a base table>)
基本上,我认为这也会收回观点。我用来识别所需表的 SQL 是:
SELECT TABLE_NAME FROM MyDatabase.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
但是,结果似乎没有TABLE_TYPE
属性是Microsoft.SqlServer.Management.Smo.TableCollection
. 根据 SQL,TABLE_TYPE 要么BASE TABLE
只有VIEW
两种可能。
如何仅识别表(而不是视图)?