Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 query

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-01-18 : 05:03:24
Hi,
There is a table tblMain with fields such as:

...
[FieldName] [varchar](50) NOT NULL,
[Operator] [varchar](6) NOT NULL,
[Value] [varchar](50) NOT NULL

code FieldName Operator Value
---------------------------------------------
xyz Currency = GBP
UIT Age > 12
YPI Currency IN USD, JPY, XXX
DSA Monitor NOT IN Toshiba, Samsung

Question:

How can the sql be built to execute the query based on the data above?
i.e.
for say, code DSA, I would like to execute the following query:
select * from tblData where Monitor not in ('Toshiba', 'Samsung')

Thanks

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-18 : 16:48:43
store the values with the quotes and the use Dynamic SQL

but...

What are you doing?

Saving previous executed queries?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-01-19 : 08:01:22
Thanks
Go to Top of Page
   

- Advertisement -