1

I have a Stored procedure that accepts a comma delimited string of IDs as a parameter

I have a UDF called Split that then splits that and returns it as a Table

In my query I return a value from a view that is another comma delimited string of IDs

In my Where statement I essentially want to say

WHERE dbo.Split(@inputstring) IN dbo.Split(view.ViewString)

And only return rows where a value in my input string exists in my View string

How can I best achieve this?

4

1 に答える 1

2

少なくとも1つのID@inputstringがリストにある場合、行を選択する必要があると思いますview.ViewStringか? もしそうなら:

WHERE EXISTS (select ID 
                 from dbo.Split(@inputstring) t1 
                      inner join dbo.Split(view.ViewString) t2 on (t1.id=t2.id))
于 2012-12-12T13:07:00.717 に答える