Monday, 17 March 2014

How to find already exist Value in sql server

How to find already exist Value in sql server


Use this query, If you want the value, which is already exists in the database:



set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[SP_insert]--(Store Procedure)
@b_Barcode varchar(100)--(Column name)
as begin
if exists (select b_Barcode from Barcode where b_Barcode=@b_Barcode)
return 0
else
insert into Barcode (b_Barcode) values(@b_Barcode)
end