0
我正在使用如果else語句,並且我想刪除創建在內部if語句旁邊的臨時表,但是當我執行語句時,我得到答案as,數據庫中已經有一個名爲'#table'的對象。 ---------------------我的代碼就像這裏輸入代碼如果其他循環,不能刪除相同的臨時表
DECLARE @RowCount INT;
SET @RowCount = 1;
IF @RowCount = 1
BEGIN
IF OBJECT_ID('tempdb..#Guarantor_Details') IS NOT NULL
DROP TABLE #Guarantor_Details
SELECT DISTINCT TOP 1 GUARANTORS.GUARANTOR_CODE
INTO #Guarantor_Details
FROM GUARANTORS
WHERE ISNULL(GUARANTORS.deleted, 0) <> 1;
DECLARE @GuarantorCount INT;
SELECT @GuarantorCount = count(*)
FROM #Guarantor_Details;
IF (@GuarantorCount = 0)
DROP TABLE #Guarantor_Details
BEGIN
IF OBJECT_ID('tempdb..#Guarantor_Details') IS NOT NULL
SELECT TOP 1 CLIENT.Last_Name
INTO #Guarantor_Details
FROM CLIENT
LEFT JOIN GUARANTORS ON GUARANTORS.GUARANTOR_CODE = CLIENT.Financial_Guarantor
END
END
------------------------------------------------------------------------