日期:2014-05-17 浏览次数:20498 次
IF OBJECT_ID(N'Test',N'U') IS NOT NULL
DROP TABLE Test
CREATE TABLE Test
( CSNTusername VARCHAR(50),
CSNTpassword VARCHAR(50),
CSNTresult INT,
CSNTgroup INT,
CSNTacctInfo VARCHAR(50)
)
INSERT INTO Test
SELECT '0000010145','42,42,42,42,',0,0,'' UNION ALL
SELECT '0000010145','42,42,42,42,',0,0,'' UNION ALL
SELECT '0000010145','42,42,42,42,',0,0,'' UNION ALL
SELECT '0000056225','42,56,49,55,53,50,',0,0,'' UNION ALL
SELECT '0000056225','42,56,49,55,53,50,',0,0,'' UNION ALL
SELECT '0000056225','42,56,49,55,53,50,',0,0,'' UNION ALL
SELECT '9100000012','46,46,46,46,46,46,',0,0,'' UNION ALL
SELECT '9100000012','46,46,46,46,46,46,',0,0,'' UNION ALL
SELECT '9100000012','46,46,46,46,46,46,',0,0,'' UNION ALL
SELECT '0000002051','47,42,45,55,56,57,',0,0,'' UNION ALL
SELECT '0000002051','47,42,45,55,56,57,',0,0,'' UNION ALL
SELECT '0000002051','47,42,45,55,56,57,',0,0,'' UNION ALL
SELECT '0000022489','48,48,48,48,',0,0,'' UNION ALL
SELECT '0000022489','48,48,48,48,',0,0,'' UNION ALL
SELECT '0000022489','48,48,48,48,',0,0,''
GO
--删除前
SELECT * FROM Test
--删除后
GO
DELETE FROM dbo.TEST WHERE TEST.%%physloc%% NOT IN (SELECT MIN(b.%%physloc%%)
FROM TEST b GROUP BY CSNTusername)
SELECT * FROM Test
/*
(15 行受影响)
CSNTusername CSNTpassword CSNTresult CSNTgroup CSNTacctInfo
-------------------------------------------------- -------------------------------------------------- ----------- ----------- --------------------------------------------------
0000010145 42,42,42,42, 0 0
0000010145