March 24, 2014 at 1:28 pm
I have been racking my brain on trying to figure out a way to do this with no luck so I thought I would post my question here to see if anyone had any ideas.
I have some data in a relational database with multiple tables but for simplicity in this question lets assume I have a Company table with company ID and lots of other fields like name, status, address, … I also have a report table that will link to the company table by company ID. In the report table I have a field called WhereClause which could have something like ‘status = ‘Yes’’ or ‘Address like ‘%South%’’. I would like to write a query that uses the value of WhereClause not the field name.
Select * from Company c inner join ReportTable rt on c.ComapnyID = rt.CompanyID where WhereClause
Any ideas?
Doing this as a cursor is not an option.
Thanks,
John
March 25, 2014 at 11:37 am
If the where clause could be almost anything, you probably will need to resort to dynamic sql. This comes with its own share of pain. Looking at your question from the 10,000 foot view- why do you need a where clause that can take almost any form?
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply