How to create Database Snapshot - SQL Server DBA T.SQL Server 2014 Create Database Best Practices - S.How to Take Database Offline and Bring it Online.How to Shrink Database And Database Files - SQL Se.How to Create Database in SQL Server 2014 - SQL Se.How to Attach and Detach Databases - SQL Server DB.SELECT OBJECT_NAME ( OBJECT_ID ), definition Use sys.all_sql_modules system view to get information if table is used The definition column of this view has definition of Stored Procedure, Views, Functions etc.You can write query as given below to check if any of the Stored Procedure or object is using the table/view you are looking for. SELECT DISTINCT OBJECT_NAME ( SD.id ) AS StoredProcedureNameName ,įROM sys.sysdepends SD INNER JOIN sys.sysobjects Oģrd method is to use the sys.all_sql_modules system view. It will not show you cross database objects ( Tables,Views) if have used in Stored Procedure or view definition. The 2nd method is to use the sys.sysdepends view with combination of sys.sysobjects to get the information. By using sp_depends, You can provide Stored Procedure Name or View name as parameter If you have used objects from other databases, this information might be misleading. One disadvantage of using sp_depends is, it will not show you tables/views which are not in current database. You can pass the view name or Stored Procedure as parameter,it will return you tables/views which are used in the object. This System Stored Procedure will return you list of table/views used by the Stored procedure/View. In this post, we are going to learn how to find out if the table is used in a Stored Procedure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |