有人可以帮忙吗我不知道我做错了什么:
IF EXISTS ( SELECT name
FROM sys.tables
WHERE name = N'MemberIdsToDelete' )
DROP TABLE [MemberIdsToDelete];
GO
SELECT mm.memberid ,
mm.aspnetuserid ,
mm.email ,
mm.RowNum AS RowNum
INTO #MemberIdsToDelete
FROM membership.members AS mm
LEFT JOIN aspnet_membership AS asp ON mm.aspnetuserid = asp.userid
LEFT JOIN trade.tradesmen AS tr ON tr.memberid = mm.memberid
WHERE asp.isapproved = 0
AND tr.ImportDPN IS NOT NULL
AND tr.importDPN <> ''
ORDER BY mm.memberid
DECLARE @MaxRownum INT
SET @MaxRownum = ( SELECT MAX(RowNum)
FROM #MemberIdsToDelete
)
DECLARE @Iter INT
SET @Iter = ( SELECT MIN(RowNum)
FROM #MemberIdsToDelete
)
DECLARE @MemberId INT
DECLARE @TrademId INT
DECLARE @UId UNIQUEIDENTIFIER
DECLARE @Successful INT
DECLARE @OutputMessage VARCHAR(200)
DECLARE @Email VARCHAR(100)
DECLARE @Username VARCHAR(100)
SELECT @MemberId = memberId ,
@UId = AspNetUserId
FROM MemberIdsToDelete
SELECT @TrademId = TradesManId
FROM trade.TradesMen
WHERE memberId = @MemberId;
WHILE @Iter <= @MaxRownum
BEGIN
SELECT *
FROM #MemberIdsToDelete
WHERE RowNum = @Iter
--more code here
SET @Iter = @Iter + 1
END
我只想检查我的表 MemberIdsToDelete 是否存在,如果存在则删除它,使用从 select 循环中通过 MemberIdsToDelete 表设置的结果创建 MemberIdsToDelete 并执行操作
我收到 RowNum 不存在的错误