-1
我正在嘗試創建兩個電子郵件地址列表,一個是當前登錄到數據庫的所有用戶列表,另一個是沒有的用戶列表。創建一個電子郵件用戶列表?
我似乎無法填充@usersin和@usersout變量,我從最終的兩個SELECT中得到一個NULL輸出......任何人都可以在我的代碼下面看一看,並告訴我它出什麼問題了?
SELECT @maxurn = MAX(ID) FROM ##tmp2
SET @urn = 1
WHILE @urn <= @maxurn
BEGIN
SET @usersin = @usersin + (SELECT [USER_NAME] + ';' FROM ##tmp2 WHERE [LoggedIn]='YES'
AND ID = @urn FOR XML PATH(''))
SELECT @urn = @urn + 1
END
SET @urn = 1
WHILE @urn <= @maxurn
BEGIN
SET @usersout = @usersout + (SELECT [USER_NAME] + ';' FROM ##tmp2 WHERE [LoggedIn]='NO'
AND ID = @urn FOR XML PATH(''))
SELECT @urn = @urn + 1
END
SELECT @usersin
SELECT @usersout