Required Query to find a SP in all the all the databases in a server atonce

  • select * from sysobjects WHERE object_id = OBJECT_ID(N'[dbo].SP_anything]') ... is used to find a particular SP in one database at a time.....but i need to find the SP in all the databases atone ,...because we have so many databases in our server....

  • select * From master.sys.All_objects where type = 'p' etc

  • Hi AnzioBake ,

    Thank you for the quick reply ...but it is not working (checked in the sql server 2005)........Can u check it once. (or) is there any other query to do this......

    pls help me out

  • A bit more work but nothing major

  • thank u 🙂

  • A bit shorter version of the code by Anzio

    sp_MSforeachdb 'if ''?'' NOT IN (''tempdb'',''master'',''model'',''msdb'')

    SELECT ''?'',Name Collate SQL_Latin1_General_CP1_CI_AS From [?].sys.all_Objects where type = ''p''

    AND [Name] NOT LIKE ''sp_%'' -- excludes system proc

    '

    SQLServerNewbieMCITP: Database Administrator SQL Server 2005

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply