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...
SETstatement inside of aCASEstatement.SET @c = CASE WHEN x THEN y ELSE z ENDis valid, butCASE WHEN x THEN SET @c = y ELSE SET @c = z ENDcertainly is not.SELECT @categoryId = (case...)