如果滿足條件,我想選擇特定的元素。請看下面我的代碼。我如何選擇CASE子句中的數據?我的辦法不起作用如果條件滿足,選擇參數
CREATE PROCEDURE [dbo].[GetUsers]
@firstName varchar(100) = '',
@isCounterSelected int,
@countries dbo.tvp_stringArray READONLY
AS
BEGIN
SET NOCOUNT ON;
SELECT [PK_UserID] AS Id
,[UserNickName]
,[description]
,CASE
WHEN @isCounterSelected = 1 THEN (NULL AS MCount, NULL AS GCount, NULL AS CCount)
ELSE ''
END
FROM [dbo].[User_Existing]
WHERE (@firstName NOT LIKE '' AND firstName LIKE @firstName + '%')
AND Country IN (SELECT inputValue FROM @countries)
什麼是你的問題? –
對不起。我剛剛編輯過。 – Matt
你現在可以檢查你的CASE語句嗎? – ProblemSolver