发布时间:2013-09-19 11:33:46来源:阅读(2048)
ALTER PROCEDURE wg_News_InsertCategory
@Name varchar(50),
@Description varchar(250),
@ImageUrl varchar(250),
@CategoryID int OUTPUT
AS
DECLARE @CurrID int
-- see if the category already exists
SELECT @CurrID = CategoryID
FROM News_Categories
WHERE Name = @Name
-- if not, add it
IF @CurrID IS NULL
BEGIN
INSERT INTO News_Categories
(Name, Description, ImageUrl)
VALUES (@Name, @Description, @ImageUrl)
SET @CategoryID = @@IDENTITY
IF @@ERROR > 0
BEGIN
RAISERROR ('Insert of Category failed', 16, 1)
RETURN 99
END
END
ELSE
BEGIN
SET @CategoryID = -1
END
关键字: SQL
949
1530
792
909
1129
1312
3336
966
1926
888
9593
5996
5523
5116
4567
4274
3415
3336
3335
3269