January 13, 2014 at 5:18 am
Hw can I get All Relationship information between tables situated at different databases in SQL Server...?
January 13, 2014 at 5:25 am
well, if there is a view or stored procedure that references a different database or a linked server, you can query for that.
take a look at the view sys.sql_expression_dependencies, and pay attention to these columns:
referenced_server_name
referenced_database_name
referenced_schema_name
referenced_entity_name
you may need to do that in each of your databases, since you are trying to discover dependancies,a dn they are "saved" local to each database.
select *
from sys.sql_expression_dependencies
Lowell
January 13, 2014 at 5:37 am
Thanks a Lot for your Reply ...:-) can you plz tell me how can get relationship information between tables on which column is used as a foreign key to refer a first table situated at different database?
January 13, 2014 at 6:08 am
it's not possible for a foreign key to reference a different database.
foreign keys can only be created within the same database as the two tables exist in.
it's possible to make a function, that returns, say 0/1 if a value exists in another database, and then use THAT to enforce a check constraint.
it's a rare situation where someone puts something like that in place, but my first example would help you find those situations.
so any references can only be inferred by using, say a udf plus a check constraint, or implied by joins in cross database views, maybe.
Lowell
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply