Hi Mary,
Obviously the first thing to do is to parse your varchar field. You stated
that your column "contains data like >50 or <2" - you need to get more
specific than that, becuase in essence, you have stored 2 different things
in the column, and the first thing you need is to split your string into 2
pieces. The only way to do that is to know what all of the possible values
for the first (comparison operator) is, so that you can identify where
tosplit the data. Of course, this would have been much easier if you had
used 2 columns to store the 2 values; that is good database design. But once
you've identified all the possible values of the first part, you can create
a loop that loops through all of them and uses the index of the last
character to determine where to split the value. Once split into 2 values,
you need to create a loop which selects from various kinds of comparison
operators that correspond to the ones in your list of possibles, and builds
a comparison statement from one of them.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Marty Underwood" <ma********@insightbb.com> wrote in message
news:bczYb.341294$xy6.1700666@attbi_s02...
Got a quick question that I cannot get to work at work!
I have a field in SQL server that is set as a varchar but contains data
like50 or <2 which is actually a target percentage. I have data in another
table stored as Decimal(14,2) that is the actual percentage. I need to
extract the two and create a conditional formatting result in a datalist.
Basically it would be something like this.
Assume actualpercentage = 30
targetpercentage = >50
If actual percentagetargetpercentage = True then forecolor= "Green"
Else
forecolor = "Red"
In actual terms it would be like
If 30>50 = True then forecolor = "Green"
Else
forecolor = "Red"
Don't worry about setting the color I can get that accomplished if I could
just build the boolean expression. And trust me I know the way it is
written here seems weird but it represents what I need to test. Basically the
target percentage is anything above 50% so I need to test and see if the actual
was greater than the target. However, like I show before the target could be
anything like <2%
Thanks for any help, a function or any mechanism for that matter would be
great.
Marty U