You'll need to pick up a book on SQL. Your = (this is what I need)... I assume is just some sort of status which tells you whether a bar code exists or not. You really can do a check and an insert in one transaction. That is:
1) Check if the bar code exists...
2) If it doesnt add it else dont add it
Here is a sample sproc:
CREATE PROCEDURE insert_barcode @barcode varchar(50),
AS
BEGIN
SET NOCOUNT ON
IF EXISTS(SELECT *
FROM MyBarCodes
WHERE barcode=@barcode
) return -1 --i'm returning -1 back to the client application..already exists
ELSE
--if im here then the barcode does not exist and should be inserted...
INSERT INTO MyBarCodes (barcode) Values (@barcode)
RETURN SCOPE_IDENTITY() --you could return the identity if you need it
Set NOCOUNT OFF
End
GO
Keeping the web experience alive -- http://www.web-impulse.com
Imperfection living for perfection -- http://jhermiz.blogspot.com/