Hi
You can simply do
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[AddToCart]
@CustomerID varchar(50),
@ProductID int,
@Quantity int
As
If Not Exists (Select 1 From table where ProductID = @ProductId)
INSERT INTO ShoppingCart (CustomerID,Quantity,ProductID) VALUES(@CustomerID,@Quantity,@ProductID)