Skip to main content

Posts

Showing posts from April, 2014

Query To Identify Dependent Objects Of A Procedure

Including one more script to my script volt. I have always wanted to easily identify the dependent objects for a procedure. The core of code was grabbed from http://www.sqlservercentral.com/scripts/Cross+Reference/108582/ , I have changed the original script to accommodate the common filter conditions and other dependent  objects that I thought was needed. The query identifies the following dependent objects -          -   Tables -          -   Views -          -   Functions -          -   Procedures   /* Parameter -- @ProcedureName ( by default it will be set to  @ProcedureName  = '-1') --  @ProcedureName  = '-1' will  -- generate dependencies for all proceudre in the currnt database --  @ProcedureName  = ' ' + '%' -- will populate the dependencies which are in the LIKE clause */ DECLARE @ProcedureName sysname SET   @ProcedureName  = '-1' --  @ProcedureName  = ' ' + '%' -- Ena

What Fields Are In My Clustered Index

Last week I had to investigate a problem with a third party databases in the Health industry and was told by the product owner to look into the potential issue and provide a set of recommendations. One of my objectives were to identify tables with clustered indexes and the composition of the index. i.e if the clustered index had multiple columns and the if the fist column was not incremental As usual,  I hope this script helps  IF OBJECT_ID ( 'TEMPDB..#Temp_Constraint_Columns' ) IS NOT NULL       DROP TABLE TEMPDB .. #Temp_Constraint_Columns CREATE TABLE #Temp_Constraint_Columns       (             IID int identity ( 1 , 1 )             , ObejctName varchar ( 100 )             , Index_Type varchar ( 50 )             , PK_YN      varchar ( 100 )             , Object_Type varchar ( 10 )             , KeyColumns varchar ( 500 )       )       INSERT INTO #Temp_Constraint_Columns        (             ObejctName