Twitter Updates

    follow me on Twitter

    Wednesday, October 12, 2005

    SQL Server - alle objecten owned by dbo maken

    Dit statement genereerd voor elk object dat niet 'owned by dbo' is een sp_changeobjectowner statement.

    SELECT 'EXEC(''sp_changeobjectowner @objname = '''''+ 
    ltrim(u.name) + '.' + ltrim(s.name) + ''''''
    + ', @newowner = dbo'')'
    FROM sysobjects s,
    sysusers u
    WHERE s.uid = u.uid
    AND u.name <> 'dbo'
    AND xtype in ('V', 'P', 'U')
    AND u.name not like 'INFORMATION%'
    order by s.name

    No comments: