tsql - Does int in (SELECT varchar...) work? -
i'm trying modify code written bey else generating model report being built in business intelligence development studio (microsoft reporting services).
i wondering if necessary?
where (convert(varchar,r.kommunenr) collate database_default in (select item dbo.split('"+ @kommune+ "', ',') split_1))" $kommune text built this: "kommune1,kommune2,kommune3,..."
is okay check int (r.kommunenr) in (select item dbo.split('"+ @kommune+ "', ',') split_1) reckon varchar. this
where (r.kommunenr in (select item dbo.split('"+ @kommune+ "', ',') split_1)) the problem can't run code, atm have code, , not permission run it.
in tsql implicit conversions, varchar cast int , not vice versa.
so second query fail if r.kommunenr int , dbo.split returns varchar not castable int.
if want benefit index on r.kommunenr, may try this:
select * r kommunenr in ( select case isnumeric(item) when 1 case when cast(item float) = cast(cast(item float) int) cast(cast(item float) int) end end dbo.split(@kommune) split1 ) this handle edge cases 1e8 numeric not directly castable int.
Comments
Post a Comment