与える:なぜSQLの場合の条件は、私が正常に動作します。このような何かエラー
select nameOfCols
from
FACost
inner join FAT as D on d.nid=a.atypeid
and
d.nid in (select item from SplitString('1,2,3,',','))
をしかし、私は、ユーザーが動的に1,2,3「の代わりに」」入力して状況に対処するためにケースを使用する場合、 'そして、それは私の場合の条件にエラーが発生します
declare @selectedAssetTypeID varchar(50)='1,2,3,'
select nameOfCols
from
FACost
inner join FAT as D on d.nid=a.atypeid
and
case when @selectedAssetTypeID<>'' then d.nid in (select item from SplitString(@selectedAssetTypeID,',')) else d.nid=1 end //error causing lines
エラーは以下のとおりです。
Msg 156, Level 15, State 1, Line 33
Incorrect syntax near the keyword 'in'.
Msg 156, Level 15, State 1, Line 33
Incorrect syntax near the keyword 'else'.
'CASE' *表現を下回っている*返すことがありますSQLデータ型のスカラー値(行ごと)。それはブール値であるために述語を評価した結果を返すことはできません.SQL Serverにはブール型のデータ型がありません。 –