1

Before I run off and write my own version from scratch, is there an API that exposes the system views in SQL Server (e.g. sys.tables and sys.procedures) to C#?

Jonathan Allen
  • 68,373
  • 70
  • 259
  • 447

1 Answers1

5

As you suggest, you can use ADO.NET to query the system catalogs.

You could also use LINQ to SQL:

  • Open Server Explorer in Visual Studio. Open a connection to the server.

  • Right-click the server and choose Change View > Object Type.

  • Under System Tables and User Tables, you can drag a system object onto a .dbml surface.


For database specific objects use SMO (SQL Server Management Objects)

In C# add Microsoft.SqlServer.Management.Smo

SQL Server Management Objects (SMO) Programming Guide

This might be of use: Reference Microsoft.SqlServer.Smo.dll

Community
  • 1
  • 1
Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
  • SMO objects are awesome. They even have a decent caching system so I don't waste cycles fetching the same information twice. – Jonathan Allen Aug 06 '14 at 05:05