text: ﻿CREATE PROCEDURE [dbo].[BugNet_Issue_CreateNewIssue]
    @IssueTitle nvarchar(500),
    @IssueDescription nvarchar(max),
    @ProjectId Int,
    @IssueCategoryId Int,
    @IssueStatusId Int,
    @IssuePriorityId Int,
    @IssueMilestoneId Int,
    @IssueAffectedMilestoneId Int,
    @IssueTypeId Int,
    @IssueResolutionId Int,
    @IssueAssignedUserName NVarChar(255),
    @IssueCreatorUserName NVarChar(255),
    @IssueOwnerUserName NVarChar(255),
    @IssueDueDate datetime,
    @IssueVisibility int,
    @IssueEstimation decimal(5,2),
    @IssueProgress int
  AS
  
  DECLARE @IssueAssignedUserId	UNIQUEIDENTIFIER
  DECLARE @IssueCreatorUserId		UNIQUEIDENTIFIER
  DECLARE @IssueOwnerUserId		UNIQUEIDENTIFIER
  
  SELECT @IssueAssignedUserId = UserId FROM Users WHERE UserName = @IssueAssignedUserName
  SELECT @IssueCreatorUserId = UserId FROM Users WHERE UserName = @IssueCreatorUserName
  SELECT @IssueOwnerUserId = UserId FROM Users WHERE UserName = @IssueOwnerUserName
  
  	INSERT BugNet_Issues
  	(
  		IssueTitle,
  		IssueDescription,
  		IssueCreatorUserId,
  		DateCreated,
  		IssueStatusId,
  		IssuePriorityId,
  		IssueTypeId,
  		IssueCategoryId,
  		IssueAssignedUserId,
  		ProjectId,
  		IssueResolutionId,
  		IssueMilestoneId,
  		IssueAffectedMilestoneId,
  		LastUpdateUserId,
  		LastUpdate,
  		IssueDueDate,
  		IssueVisibility,
  		IssueEstimation,
  		IssueProgress,
  		IssueOwnerUserId
  	)
  	VALUES
  	(
  		@IssueTitle,
  		@IssueDescription,
  		@IssueCreatorUserId,
  		GetDate(),
  		@IssueStatusId,
  		@IssuePriorityId,
  		@IssueTypeId,
  		@IssueCategoryId,
  		@IssueAssignedUserId,
  		@ProjectId,
  		@IssueResolutionId,
  		@IssueMilestoneId,
  		@IssueAffectedMilestoneId,
  		@IssueCreatorUserId,
  		GetDate(),
  		@IssueDueDate,
  		@IssueVisibility,
  		@IssueEstimation,
  		@IssueProgress,
  		@IssueOwnerUserId
  	)
  RETURN scope_identity()
  