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 2005 Forums
 Transact-SQL (2005)
 how to convert varchar to int while checking the c

Author  Topic 

Ambikaa
Starting Member

43 Posts

Posted - 2008-08-06 : 08:35:35
Hi All,

how to convert varchar to int while checking the condition? i have a table in that prty_price column is varchar datatype
if i below query , the result that i am getting wrong
SELECT prty_id, prty_genid,StateId,City,prty_Type,prty_SqrFootage,Prty_NoOfBedRooms,prty_NoOfBathRooms,prty_Price,prty_status FavStatus FROM tbl_Property WHERE (prty_Price >= '10000' AND prty_Price <= '60000') AND prty_Deleted=0

could u suggest me to convert the varchar to int in the condition?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-06 : 08:37:35
SELECT prty_id, prty_genid,StateId,City,prty_Type,prty_SqrFootage,Prty_NoOfBedRooms,prty_NoOfBathRooms,prty_Price,prty_status FavStatus FROM tbl_Property WHERE (cast(prty_Price as int) >= 10000 AND cast(prty_Price as int) <= 60000) AND prty_Deleted=0

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-08-06 : 08:37:40
where cast(prty_price as int) between 10000 and 60000

Em
Go to Top of Page
   

- Advertisement -