CREATE TABLE #result
( id INT IDENTITY(1, 1) , objectid INT , scemaid INT , NAME VARCHAR(300) )INSERT INTO #result ( objectid , scemaid , NAME ) SELECT object_id , schema_id , name FROM sys.objects WHERE schema_id = 6 AND type = 'P'CREATE TABLE #result2
( id INT IDENTITY(1, 1) , objectid INT , scemaid INT , NAME VARCHAR(300) )INSERT INTO #result2
( objectid , scemaid , NAME ) SELECT sys.objects.object_id , sys.objects.schema_id , sys.objects.name FROM sys.objects INNER JOIN #result ON #result.name = sys.objects.name AND sys.objects.schema_id = 1 AND sys.objects.type = 'P' DECLARE @tempid INT,@MaxId INTSET @tempid=1SELECT @MaxId=MAX(id) FROM #result2
WHILE @tempid<
BEGINDECLARE @spname VARCHAR(300)SELECT @spname=NAME FROM #result2 WHERE IF @spname IS NOT NULLBEGINSELECT @spname='DROP PROC EXEC ()ENDSET @tempid=@tempid+1ENDSET @tempid=1
SELECT @MaxId=MAX(id) FROM #result
WHILE @tempid<
BEGINDECLARE @spname1 VARCHAR(300)SELECT @spname1=NAME FROM #result WHERE IF @spname1 IS NOT NULLBEGINSELECT @spname1='ALTER SCHEMA dbo TRANSFER [dyoga36].'+''+@spname1+''EXEC ()ENDSET @tempid=@tempid+1END--ALTER SCHEMA dbo TRANSFER [dyoga36].UpdateSendPointWithPatch
--UPDATE sys.objects--SET sys.objects.schema_id=1--FROM sys.objects--INNER JOIN #result ON #result.objectid = sys.objects.object_id--exec Changename 'dyoga36','dbo' --将cwa1034所有者更改为dbo