DECLARE @old sysname, @sql varchar(1000)
SELECT
@old = 'oldOwner_CHANGE_THIS'
, @sql = '
IF EXISTS (SELECT NULL FROM INFORMATION_SCHEMA.TABLES
WHERE
QUOTENAME(TABLE_SCHEMA)+''.''+QUOTENAME(TABLE_NAME) = ''?''
AND TABLE_SCHEMA = ''' + @old + '''
)
ALTER SCHEMA dbo TRANSFER ?'
EXECUTE sp_MSforeachtable @sql
SELECT
@old = 'oldOwner_CHANGE_THIS'
, @sql = '
IF EXISTS (SELECT NULL FROM INFORMATION_SCHEMA.TABLES
WHERE
QUOTENAME(TABLE_SCHEMA)+''.''+QUOTENAME(TABLE_NAME) = ''?''
AND TABLE_SCHEMA = ''' + @old + '''
)
ALTER SCHEMA dbo TRANSFER ?'
EXECUTE sp_MSforeachtable @sql
No comments :
Post a Comment