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)
 Question in Select statement

Author  Topic 

mapperkids
Yak Posting Veteran

50 Posts

Posted - 2007-03-26 : 12:45:30
Hi,

How can convert a text field to numeric when in a select statment?

"SELECT * from tablea where fieldA > 1000"

but fieldA in the table is defined as CHAR, how can I convert it to numeric for comparsion in the select statement.

Thanks a lot !

X002548
Not Just a Number

15586 Posts

Posted - 2007-03-26 : 12:48:00
CONVERT(int,fieldA)



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

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-27 : 00:49:33
SELECT * from tablea where fieldA > '1000'
and len(fieldA) >= 4


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -