SQL Conditional Select from SharePoint
Posted
by
user3320324
on Stack Overflow
See other posts from Stack Overflow
or by user3320324
Published on 2014-05-30T18:49:11Z
Indexed on
2014/05/31
3:26 UTC
Read the original article
Hit count: 163
I'm creating a search page on our SharePoint site that will allow users to find results from a SQL table by either performing a search from a text box @Param1, or selecting a value from a dropdown @SiteParam.
My SQL SelectStatement is
SELECT * FROM [Routing]
WHERE [Site] LIKE
CASE WHEN @Param1 IS NOT NULL
THEN '%' + @Param1 + '%'
ELSE @SiteParam
This works great in SQL when I declare the parameters and set values for the search, but not so much in SharePoint.
I've been able to get it to work if I don't do the case and just use 1 of the parameters, but I haven't found a way to get it to do either of them.
Any help is appreciated! Thanks
© Stack Overflow or respective owner