Answers for "avoid duplicate record"

0

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
Posted by: Guest on May-06-2021

Browse Popular Code Answers by Language