Selman ALPDÜNDAR

MSSQL Server stored procedure

CREATE PROCEDURE ProductInsert(
@ProductName varchar(25),
@Price int,
@ProductInStock int)
AS
IF EXISTS(SELECT * FROM PRODUCTS WHERE ProductName=@ProductName)
 BEGIN
 PRINT 'This product already there is ';
 END
 ELSE 
 BEGIN
  INSERT INTO PRODUCTS (ProductName,Price,ProductInStock) VALUES (@ProductName,@Price,@ProductInStock)
END



Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.