• I rewrite the script as this:

    USE master

    GRANT VIEW SERVER STATE TO [mydomain\sys$swind]

    GRANT VIEW ANY DEFINITION TO [mydomain\sys$swind]

    GRANT EXECUTE ON xp_readerrorlog TO [mydomain\sys$swind]

    EXECUTE sp_MSforeachdb 'USE [?]; CREATE USER [mydomain\sys$swind] FOR LOGIN [mydomain\sys$swind]'

    USE msdb

    EXEC sp_addrolemember N'db_datareader', [mydomain\sys$swind]

    It works great.

    And by replacing sp_adduser with create user, there is no schema created for the user for all the databases except one - master, why in master database the user still own a schema that is the same name as the login name?

    Thanks