ghx88

使用Exists关键字检查所查的数据是否存在

Create Procedure AddUniqueProduct

  @ProductName NVarchar(80),
  @UnitPrice Money

AS

if Exists
  BEGIN
    select ProductName
    From Products
    Where ProductName =@ProductName
    Return 1
  END
else
  BEGIN
  Insert Products(ProductName,UnitPrice)
         Values(@ProductName,@UnitPrice)
  return 0
  END

posted on 2005-03-26 10:00  ghx88  阅读(203)  评论(0)    收藏  举报

导航