0
我使用Microsoft SQL Server的相同字符串消息2005年交叉聯接總是具有
我想有一臺輸出與關於交叉重複的值只含有與一列一個表聯接的列相同的字符串消息 我認爲用「字符串消息」進行交叉連接應該是正確的方法。
爲什麼下面的腳本不起作用?
DECLARE @IN_CodesTable TABLE
(
CodesValues NVARCHAR(60)
)
INSERT INTO @IN_CodesTable VALUES('CODE_BB^&')
INSERT INTO @IN_CodesTable VALUES('CODE_1234')
INSERT INTO @IN_CodesTable VALUES('CODE_BB^&')
INSERT INTO @IN_CodesTable VALUES('CODE_$%^&')
INSERT INTO @IN_CodesTable VALUES('CODE_BB^&')
INSERT INTO @IN_CodesTable VALUES('CODE_BB^&')
INSERT INTO @IN_CodesTable VALUES('CODE_1234')
SELECT *
FROM
(
SELECT DISTINCT CodesTable
FROM @IN_CodesTable
WHERE CodesTable IN
(SELECT CodesValues
FROM @IN_CodesTable
GROUP BY CodesTable
HAVING COUNT(*) > 1
)
)
CROSS JOIN
(
SELECT 'You have duplicates!' AS DupMessage
)