Duplicate Record Delete code example
Example: avoid duplicate record
alter procedure [dbo].[sp_InsertBankName]
(
@bankname as varchar(50)
,@banknamea as nvarchar(50)
)
as
begin
declare @bankid as varchar(10)
declare @bCount as int
select @bCount = count(bankname) from bankname where bankname = @bankname
if @bCount = 0
begin
select @bankid=isnull(max(convert(int,bankid)),0)+1 from bankname
insert into bankname
(bankid,bankname,banknamea)
values (@bankid,@bankname,@banknamea)
end
end