Universal stored procedure. Find the deletion of unique records

zhaozj2021-02-16  105

Universal stored procedure. Find the deletion of unique records

/ * Name: spAll_DeleteNoneUnique input: output table name and a list of fields to be queried: No call: spAll_DeleteNoneUnique table names, field list Description: Common delete stored procedure to find a non-unique record of: Dili JF Senders e-mail: dili@wellknow.net website : http://www.wellknow.net Update: 20040610 Support: http://bbs.wellknow.net copyright: Please specify the source: Create the future 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 record number,' 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 nonene

Go

转载请注明原文地址:https://www.9cbs.com/read-10780.html

New Post(0)