set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: Øyvind Isaksen
-- Create date: 06/01/2009
-- Description: Adds or updates user category
-- =============================================
ALTER PROCEDURE [dbo].[spSetUserCategory]
(
@CategoryId smallint = null,
@Name varchar(128),
@Description varchar(256),
@SortOrder smallint,
@ParentId smallint = null,
@SiteId smallint,
@OutputCategoryId smallint = null OUTPUT
)
AS
BEGIN
SET NOCOUNT ON;
IF not exists (select id from tblUserCategory where id=@CategoryId)
BEGIN
insert into tblUserCategory
([Name], Description, SortOrder, ParentId, SiteId)
values
(@Name, @Description, @SortOrder, @ParentId, @SiteId)
SELECT @OutputCategoryId = SCOPE_IDENTITY()
END
ELSE
BEGIN
update tblUserCategory
set [Name]=@Name, Description=@Description, SortOrder=@SortOrder, ParentId=@ParentId, SiteId=@SiteId
where Id = @CategoryId
SELECT @OutputCategoryId = @CategoryId
END
END
|