• Looks like your database server is case sensitive (like mine.)

    change SYSNAME to sysname and you should be ok.

    Also sp_msforeachdb will have to become sp_MSforeachdb

    Regards,

    David.