0
我正在嘗試更新所有表,特效和視圖的特定模式;但是,我收到一個權限錯誤,我嘗試了一切。如何批量更新SQL模式
有人可以幫助顯示正確的方式來設置下面的查詢的權限,不會收到下面的錯誤。
查詢
USE CAD
DECLARE @OldSchema VARCHAR(200)
DECLARE @NewSchema VARCHAR(200)
DECLARE @SQL nvarchar(4000)
SET @OldSchema = 'Storefront'
SET @NewSchema = 'CadType'
DECLARE tableCursor CURSOR FAST_FORWARD FOR
SELECT 'ALTER SCHEMA ['+ @OldSchema +'] TRANSFER [' + @NewSchema + '].[' + DbObjects.Name + '];' AS Cmd
FROM sys.Objects DbObjects
INNER JOIN sys.Schemas SysSchemas ON DbObjects.schema_id = SysSchemas.schema_id
WHERE SysSchemas.Name = @OldSchema
AND (DbObjects.Type IN ('U', 'P', 'V'))
OPEN tableCursor
FETCH NEXT FROM tableCursor INTO @SQL
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @SQL
EXEC (@SQL)
FETCH NEXT FROM tableCursor INTO @SQL
END
CLOSE tableCursor
DEALLOCATE tableCursor
PRINT '*** Finished ***'
ERROR
ALTER SCHEMA [Storefront] TRANSFER [CadType].[proc_UpdateVertical];
Msg 15151, Level 16, State 1, Line 1
Cannot find the object 'proc_UpdateVertical', because it does not exist or you do not have permission.
ALTER SCHEMA [Storefront] TRANSFER [CadType].[proc_UpdateElevationQty];
Msg 15151, Level 16, State 1, Line 1
Cannot find the object 'proc_UpdateElevationQty', because it does not exist or you do not have permission.
ALTER SCHEMA [Storefront] TRANSFER [CadType].[proc_Update_Set_LeafIsActive];
Msg 15151, Level 16, State 1, Line 1
很高興我問這個問題,因爲我的印象是,該模式是移動,這是不是這樣的。它是正在轉移的表格而不是圖表。我的問題是,我還沒有創建一個CadType架構,並將其設置爲登錄用戶。幾乎尷尬地承認這一點。 –