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 2000 Forums
 Transact-SQL (2000)
 Comparation in varchar data field

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2005-01-05 : 12:35:56
I have a table called Blood Pressure

ID BP
1 130/88
2 150/80
3 117/72
4 112/72
5 130/80
6 154/110

I want to retrieve the ID which has BP <= 130/80(High / Low)
The result should looks like:

ID BP
3 117/72
4 112/72
5 130/80


How can I do this comparison since BP is the varchar data type?





nr
SQLTeam MVY

12543 Posts

Posted - 2005-01-05 : 12:56:35
something like
where convert(int,left(BP,charindex('/',BP)-1)) <= 130
and convert(int,right(BP,charindex('/',reverse(BP))-1)) <= 80

You should store the two values in different columns.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -