Login    
 
 
 
 
Text/HTML
  
You are here :: Blogs Saturday, May 19, 2012

Search
Note: This uses the internal blog search engine. The Google search engine is also available at the top of the page.
  
Disclaimer

Please review the site disclaimer before downloading or using content found on this site

  
Categories
  
DEVSHED Blog
As always, I welcome your comments!
Jun 20

Written by: Steve Gray
6/20/2011 9:04 AM  RssIcon

I’m writing a new web site (which I hope to announce soon) and I need to use a dynamic where clause. The user is going to enter some filter conditions on the web site and the data that they see will be filtered by that criteria. I’m using the RadFilter control by Telerik; it basically gives me the complete where clause.

So, I have a something like

Select * from myTable Where @WhereClause

Of course, that’s not valid SQL. What to do? In the end, I’ll have to use my least favorite solution, dynamic SQL using the EXEC command. I’ll change the statement above into

DECLARE @sql varchar(1000)

SET @sql = ‘SELECT * FROM myTable WHERE ‘ + @WhereClause

exec(@sql)

Ug. At anyrate, the best advice that I could find on the subject was here: http://sommarskog.se/dyn-search.html, I didn’t want to lose the reference so I’ll blog it.

Tags:
Categories:
Location: Blogs Parent Separator DEVSHED Blogs Child Separator SQL
As always, I welcome your comments!
  
 
 
Home | Products | Blogs | Contact Us | Links | God's Plan
Privacy Statement | Terms Of Use
 
Copyright 2011 by Devshed.us