14 October,2015 by Tom Collins
A dependency is recorded in the database engine when a SQL Server object refers to another SQL Server object. Now, the question arises that what are a referenced entity and a referencing entity? An object, which is referred to by another object is called a referenced entity. An object that references another object in its definition and the system catalog stores that definition, then that object is called a referencing entity. For example in a view on a table, the table is the referenced entity and the view is a referencing entity.
Whenever a database is being developed, a relationship is established between those objects. A slight change made in the object might produce an effect on another object. The relationship between objects is made in order to share data and provide information. In order to avoid making any changes to the other objects while you don’t need a field in a table, check for object dependencies instead of deleting that field straightaway. An object dependency can be made to make sure that the field you want to delete is not used in another table.
Merits:
How to view dependency information?
For keeping track of Object Dependencies, there are two new Dynamic Management Functions namely: sys.dm_sql_referenced_entities and sys.dm_sql_referencing_entities , a System View namely: sys.sql_expression_dependencies and Not available or Unresolved Entity.
Here, users should make a note that this script works in SQL Server version 2008 and above and a schema name should be also included while specifying the stored procedure name.
Here also, the schema name should be included, while specifying the table name. Without doing this, dependencies will not be display by the result.
sys.sql_expression_dependencies System or Catalog View: This investigation tool consists of one row for each by name dependency on a user-defined entity in the current database. There are basically two types of dependencies tracked by the database engine in SQL Server 2008 that are:
1. Schema-bound Dependency: This relationship between two objects prevents the referenced objects from dropping or getting modified till the existence of the referenced object.
2. Non-schema-bound Dependency: This relationship doesn't prevent the referenced object from dropping or getting modified.
Not available or Unresolved Entity: Under this script, the dependency type cannot be determined.
Using SQL Server Management Studio: This has an attractive feature namely Object Explorer that enables the user to browse, select, and act upon any of the objects within the server. The objects dependent on another object of interest can also be viewed and also those on which it depends on. SQL Server Management Studio also gives a better hierarchical view of the dependencies.
Author Bio: Priyanka Chouhan is a technical writer in Stellar Data Recovery with 5 years of experience and has written several articles on SQL server & SharePoint. In the spear time she loves reading and gardening.
SQL Server - Open SSMS on the Command Line - SQL Server DBA
DROP SCHEMA script for multiple sql database users - SQL Server ...
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |