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.
Author |
Topic |
keyursoni85
Posting Yak Master
233 Posts |
Posted - 2010-12-01 : 10:47:52
|
Hi i want to use operator dynamically in my query..my data in table is like..ID speeds speedOperator1 52 >3 45 >=4 74 =65 43 < I want to use above table filteration likeselect * from tablename where speeds [speedOperator] [someValue]Please help it urgent. please :) |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-01 : 10:53:15
|
will need either dynamic sql or a lot of if statements.Actually I think you will have to loop through the table and execute each row.Maybe create a function to which you pass the values and return a 1 or 0?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
keyursoni85
Posting Yak Master
233 Posts |
Posted - 2010-12-01 : 12:12:00
|
Thanks for reply..but isn't is any other way to achieve this dynamic operator..please help any other way if you find... |
|
|
TimSman
Posting Yak Master
127 Posts |
Posted - 2010-12-01 : 12:15:58
|
I don't understand what you are trying to accomplish. You want to pass in a value, and use that value in a comparison statement that is build using the value from the speedOperator in the table, correct?If so, I'm not sure how the data you get is going to be meaningful, as you never really know what you're going to get back. |
|
|
keyursoni85
Posting Yak Master
233 Posts |
Posted - 2010-12-01 : 12:25:32
|
yes..actually my comparison will be against one row..I filter one unit's informationeg. speed = 17then i match it with all records with specified criterias and operatorsand then returns with matched criteriaIt matches like belowselect * from tbl_FilterCriteriawhere @speed [operator] speed[table column name] |
|
|
|
|
|