Home Forums SQL Server 2005 Administering Script all Stored procs for all databases on a server RE: Script all Stored procs for all databases on a server

  • the OBJECT_NAME function has a second , optional parameter for the db_id for exactly this reason;

    this works in 2005 and above;

    sp_msforeachdb '

    select

    object_name(s.object_id,db_id(''?'')),

    s.*, p.*

    from ?.sys.sql_modules s

    inner join ?.sys.procedures p

    on s.object_id = p.object_id'

    the schema_name() function does not have the optional parameter in 2005, so if you need the schema (assuming you have otehrs than dbo) that might take some more work.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!