我正在尝试在Azure SQL数据库上创建一个存储过程,该存储过程具有对其他数据库表的删除查询,并在Azure SQL数据库的同一数据库表中插入查询
为交叉数据库表创建外部表并重写查询
这是实际的示例过程代码:
CREATE PROCEDURE [dbo].[SP_TestAzureProcedure]
@UID bigint
AS
BEGIN
DECLARE @FetchedCustomerID bigint=0;
SELECT @FetchedCustomerID=CustomerID FROM Database1.dbo.Customers
WHERE UID=@UID
DELETE FROM Database1.dbo.CustAMLLinksForVerification
WHERE CustomerID NOT IN
(
SELECT DISTINCT C.CustomerID FROM Database1.dbo.Customers C
INNER JOIN AML_WC_MasterList WC ON REPLACE(ISNULL(C.Name,''),' ','')
=REPLACE(ISNULL(WC.FirstName,'')+ISNULL(WC.LastName,''),' ','')
WHERE WC.UID = @UID
)
AND UID = @UID AND ISNULL(MatchFieldIndex,0)=1 AND CustomerID <>
@FetchedCustomerID
END
迁移到Azure数据库后,使用如下外部表重写查询
CREATE PROCEDURE [dbo].[SP_TestAzureProcedure]
@UID bigint
AS
BEGIN
DECLARE @FetchedCustomerID bigint=0;
SELECT @FetchedCustomerID=CustomerID FROM dbo.Customers
WHERE UID=@UID
DELETE FROM dbo.CustAMLLinksForVerification
WHERE CustomerID NOT IN
(
SELECT DISTINCT C.CustomerID FROM dbo.Customers C
INNER JOIN AML_WC_MasterList WC ON REPLACE(ISNULL(C.Name,''),' ','')
=REPLACE(ISNULL(WC.FirstName,'')+ISNULL(WC.LastName,''),' ','')
WHERE WC.UID = @UID
)
AND UID = @UID AND ISNULL(MatchFieldIndex,0)=1 AND CustomerID <>
@FetchedCustomerID
END
当我尝试创建存储过程时遇到以下错误 “外部表不支持DML操作”
如何在Azure数据库中解决此问题?