Sunday, September 9, 2007

To get the list of procedures that have a certain parameter

-- SQL 2005
-- To get the list of procedures that have a certain parameter

declare @parametername varchar(100)
set @parametername = '@userid'
select o.name as ObjectName, o.type as ObjectType, p.name as Parameter, t.name as DataType, p.max_length, p.[precision], p.scale
from sys.parameters p
inner join sys.types t
on p.user_type_id=t.user_type_id
inner join sys.objects o
on p.object_id=o.object_id
where p.name=@parametername

- To get the list of SPs or functions that depend on a certain function

select object_name(object_id)
from sys.sql_dependencies
where referenced_major_id=object_id('ufn_AlpIntlistToTbl')
-- function Name and class in (0,1)

No comments: