我在 Synapse 专用 SQL 池中有这个存储过程,它将临时表重命名为主表。
ALTER PROCEDURE [dbo].[RenameStagingTableToDedicatedTable]
(
@DedicatedTableName VARCHAR(MAX)
)
AS
BEGIN
-- Check if the Dedicated table exists
IF EXISTS (SELECT 1 FROM sys.objects WHERE type = 'U' AND name = @DedicatedTableName)
BEGIN
-- Rename the staging table to the Dedicated table
EXEC sp_rename 'gold.Service_Staging', 'gold.Service'
-- Drop the existing Dedicated table
EXEC ('DROP TABLE ' + @DedicatedTableName)
END
ELSE
BEGIN
-- The Dedicated table does not exist, so rename the staging table to the Dedicated table
EXEC sp_rename 'gold.Service_Staging', 'gold.Service'
END
END
GO
执行此 SP 时,出现以下错误:
为过程或函数 sp_rename 提供的参数数量不足。
有什么想法吗?
sp_rename
在 Azure Synapse Analytics 中处于预览状态:
适用于:Azure Synapse Analytics
在 Azure Synapse Analytics 的 sp_rename(预览版)中,COLUMN 是 强制值指定要重命名的对象类型是 列,并且必须始终包含在 sp_rename 语句中。 A 仅当列不是分布列时才能重命名。
看来你目前只能重命名列(这看起来很奇怪)