I would like to prepare procedure which will take 2 arguments (Int, string) If some row will exist in table I will get @dane = 1; and in the end I would like to select @dane but my procedure is not good. I can not use return @dane.
USE [SS]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [permission].[CheckSkill]
(
@SkillId INT, -- Identyfikator użytkownika
@Description NVARCHAR(100) = NULL
)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @dana as int
SET @dana = 0
-- this is redundant:
--SET @Description = RTRIM(LTRIM(ISNULL(@Description,'')))
IF EXISTS (SELECT * FROM permission.UserXSkill Where permission.UserXSkill.SkillId = @SkillId)
BEGIN
SET @dana = 1;
END
SELECT @dana AS ID;
END
GO
Topic [closed] Thanks for help.
You need to use
SETorSELECTwhen assigning a value to a variable.EXISTSseems to serve the requirement in yourIFblockThe
@Descriptionparameter is unused and is redundant