﻿ALTER PROCEDURE [dbo].[sp_GroupsInsert]
	@SerialNumber       NVARCHAR (255),
	@Picture			NVARCHAR (255) = NULL,
	@DisplayName		NVARCHAR (255),
	@Embedded			BIT,
	@Description		NVARCHAR (255),
	@LastModified		DATETIME,
	@LastModifiedBy		NVARCHAR (255),
	@StaticGroupId		int = NULL,
	@ExtraProperties	NVARCHAR (MAX),
	@errorNumber		int OUTPUT,
	@errorMessage		NVARCHAR (255) OUTPUT,
	@new_id				int OUTPUT
AS
BEGIN
	SET NOCOUNT ON;
	SET @errorNumber=0
	SET @errorMessage=''
	INSERT INTO Groups (SerialNumber, [Picture], DisplayName, [Description], Embedded,  LastModified,  LastModifiedBy,  StaticGroupId,  ExtraProperties) 
			   VALUES (@SerialNumber, @Picture, @DisplayName, @Description, @Embedded, @LastModified, @LastModifiedBy, @StaticGroupId, @ExtraProperties)

	SET @new_id = scope_identity();
	IF(@@error != 0)
	BEGIN
		SET @errorNumber = error_number()
		SET @errorMessage = error_message()
	END
END