• I have made some modification to your script. To bad but the environment I am in is using database names with spaces in it. This is the reason I had to update your script a little bit. Nothing mayor, but in order to make it work I have added [] around the ? in command to execute sp_MSForEachDB. See the script below. I know it is a bad thing to have a database with spaces in the name, but what can I do if you are getting into a environment without any standards before I came there. 😛

    --

    -- SQL 2005 DDL Auditing Solution

    --

    -- Stand up test for all database level auditing and server auditing

    --

    -- Sean Elliott

    -- sean_p_elliott@yahoo.co.uk

    --

    -- July 2010

    --

    select * from dbadata..ServerAudit

    exec sp_MSForEachDb 'if ''[?]'' != ''[tempdb]'' begin use [?];print ''[?]'';select * from DatabaseAudit end'

    exec sp_MSForEachDB 'use [?]; print ''[?]''; create table aa_test_ddl_audit (col1 int)'

    exec sp_MSForEachDB 'use [?]; print ''[?]''; drop table aa_test_ddl_audit'