Technical Article

Where_Am_I_With_DB

,

Updated Where_Am_I script to add database. This way you can park it in your master db and call it anytime you need it for another project/db.

CREATE  procedure uspWhereAmI
@cDB varchar(255), @cString varchar(1000)
AS
set nocount on
Select @cString = 'select substring( o.name, 1, 35 ) as Object, count(*) as Occurences, ' +
'case ' +
' when o.xtype = ''D'' then ''Default'' ' +
' when o.xtype = ''F'' then ''Foreign Key'' ' +
' when o.xtype = ''P'' then ''Stored Procedure'' ' +
' when o.xtype = ''PK'' then ''Primary Key'' ' +
' when o.xtype = ''S'' then ''System Table'' ' +
' when o.xtype = ''TR'' then ''Trigger'' ' +
' when o.xtype = ''U'' then ''User Table'' ' +
' when o.xtype = ''V'' then ''View'' ' +
'end as Type ' +
'from ' + @cDB + '.dbo.syscomments c join sysobjects o on c.id = o.id ' +
'where patindex( ''%'  + @cString + '%'', c.text ) > 0 ' +
'group by o.name, o.xtype ' +
'order by o.xtype, o.name'

Execute( @cString )
Return

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating