CREATE PROCEDURE [dbo].[InsertComment] @ProductID int, @Comments VARCHAR(255)
AS
BEGIN
IF ((select count(*) from
gosalesdw.ProductComments
where ProductID = @ProductID) = 0)
INSERT INTO gosalesdw.ProductComments VALUES (@ProductID,@
Comments)
ELSE
UPDATE gosalesdw.ProductComments
SET Comment = @Comments WHERE ProductID = @ProductID
END
Select ProductID,Comment from gosalesdw.ProductComments
GO提示 必须声明标量变量 "@"
AS
BEGIN
IF ((select count(*) from
gosalesdw.ProductComments
where ProductID = @ProductID) = 0)
INSERT INTO gosalesdw.ProductComments VALUES (@ProductID,@
Comments)
ELSE
UPDATE gosalesdw.ProductComments
SET Comment = @Comments WHERE ProductID = @ProductID
END
Select ProductID,Comment from gosalesdw.ProductComments
GO提示 必须声明标量变量 "@"
Comments)
这换行了 连在一起写
AS
BEGIN
IF ((select count(*) from
gosalesdw.ProductComments
where ProductID = @ProductID) = 0)
INSERT INTO gosalesdw.ProductComments VALUES (@ProductID,@Comments) --多了换行符
ELSE
UPDATE gosalesdw.ProductComments
SET Comment = @Comments WHERE ProductID = @ProductID
END
Select ProductID,Comment from gosalesdw.ProductComments
GO
AS
BEGIN
IF ((select count(*) from
gosalesdw.ProductComments
where ProductID = @ProductID) = 0)
INSERT INTO gosalesdw.ProductComments VALUES (@ProductID,@Comments)
ELSE
UPDATE gosalesdw.ProductComments
SET Comment = @Comments WHERE ProductID = @ProductID
END
Select ProductID,Comment from gosalesdw.ProductComments
GO
可能是你里面加了go语句.
或者@ProductID int, @Comments VARCHAR(255)
这行的中英文标点有关系
AS
BEGIN
IF ((select count(*) from
gosalesdw.ProductComments
where ProductID = @ProductID) = 0)
INSERT INTO gosalesdw.ProductComments VALUES (@ProductID,@Comments)
ELSE
UPDATE gosalesdw.ProductComments
SET Comment = @Comments WHERE ProductID = @ProductID
END
Select ProductID,Comment from gosalesdw.ProductComments
GO