Declare @CategoryID as int
BEGIN
SELECT
(CASE
WHEN EXISTS(
SELECT t0.Categoryid AS [EMPTY]
FROM Categories AS [t0]
WHERE [t0].Categoryname = @CategoryName
) THEN 1
ELSE 0
END) AS [value]
I want to set my variable inside exists block with t0.Categoryid. How can that be done?
I want to replace then 1 to the category id value...
SET
statement inside of aCASE
statement.SET @c = CASE WHEN x THEN y ELSE z END
is valid, butCASE WHEN x THEN SET @c = y ELSE SET @c = z END
certainly is not. – LejeuneSELECT @categoryId = (case...)
– Granny