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
------------------------------------------------------------------------