• jayoub1 (4/8/2013)


    Thanks, but I may need an example to learn how to do this.

    This is a typical query that I would have to run on each database in the instance

    use [msdb]

    select user_name(o.schema_id) as [shema], o.name as [object],

    o.type_desc as [type],

    o.create_date as [create date]

    from sys.all_objects o, sys.sql_modules s

    where o.object_id = s.object_id

    and s.definition is not null

    and o.is_ms_shipped = 0

    order by user_name(o.schema_id), o.name

    How would I use the sp_msforeachdb to execute this. Also how will the resultes come out when you have several databases.

    Your help is appriciated

    What have you tried? Short of writing this for you there isn't much else to offer. There are plenty of examples online.

    FWIW you should consider moving to the ANSI-92 style join instead of the older style join.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/