HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How can I get a list of tables contained in a database diagram?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
cantablescontaineddatabasediagramgethowlist

Problem

I need to get a list of the tables contained in a diagram in SQL Server. How can I do it using an SQL script?

I don't need a list of tables in the database, but the list of tables contained in a diagram of the database in SQL Server 2008r2/2012.

Solution

Although this question is a year old, if anyone stumble over this, I've posted a solution to make that possible here:

http://www.codeproject.com/Messages/4914888/Search-through-the-binary-for-all-contained-texts.aspx

The trick is to extract all ASCII characters in the diagram binary, you'll see that all table names are in there as simple text. That seems to be the reason why a diagram is also destroyed if you rename a table with a script - because it doesn't use a table ID to identify the table but the table name. If it's no longer there, the diagram is not usable anymore.

With this method you can identify which diagrams contains a specific table.

Context

StackExchange Database Administrators Q#50577, answer score: 4

Revisions (0)

No revisions yet.