/*
名称:spAll_DeleteNoneUnique
输入:要查询的表名和字段列表
输出:无
调用:spAll_DeleteNoneUnique 表名, 字段列表
说明:通用存储过程.查找删除非唯一的记录
作者:Dili J.F. Senders
邮件:dili@wellknow.net
网站:http://www.wellknow.net
更新:20040610
支持:http://bbs.wellknow.net
版权:转述时请注明来源:用思维创造未来的Wellknow.net
*/
CREATE PROCEDURE spAll_DeleteNoneUnique
/*
(
@parameter1 datatype = default value,
@parameter2 datatype OUTPUT
)
*/
(
@TableName VARCHAR(50),
@Fields VARCHAR(500)
)
AS
SET NOCOUNT ON
DECLARE @sSQL VARCHAR(1000)
SET @sSQL = 'SELECT COUNT(*) AS 记录数, '
SET @sSQL = @sSQL + @Fields
SET @sSQL = @sSQL + ' FROM ' + @TableName
SET @sSQL = @sSQL + ' GROUP BY ' + @Fields
SET @sSQL = @sSQL + ' HAVING (COUNT(*) > 1)'
PRINT @sSQL
--EXEC(@sSQL)
--SELECT * FROM StockReceiveDQ
SET NOCOUNT OFF
GO