Getting System Tables And Views Thru Sqlconnection
I am trying to get all tables from a LocalDB database in C# (VS 2012) When using an OleDbConnection I can do string[] restrictions = new string[4]; connection.GetSchema('Tables',
Solution 1:
An alternative method is a query of the SQL Server catalog views.
SELECT
OBJECT_SCHEMA_NAME(object_id) AS SchemaName
, name AS ObjectName
, type_desc AS ObjectType
FROM sys.system_objects
WHERE
type_desc IN('USER_TABLE', 'SYSTEM_TABLE', 'VIEW')
UNION ALL
SELECT
OBJECT_SCHEMA_NAME(object_id) AS SchemaName
, name AS ObjectName
, type_desc AS ObjectType
FROM sys.objects
WHERE
type_desc IN('USER_TABLE', 'SYSTEM_TABLE', 'VIEW');
Post a Comment for "Getting System Tables And Views Thru Sqlconnection"