By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,856 Members | 2,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,856 IT Pros & Developers. It's quick & easy.

How to convert a Varchar into a Int with sql 2000?

P: 73
I have a sql 2000 Database table that I am trying to compare the data.The Data that i Am working with is a Varchar and I want to compare it to an int value. Currently now when I do this is does not take check all values. I am trying to see if the varchar is smaller than the int value. How can I convert the varchar value into a Int with the SQL Select Statement.
Sep 16 '08 #1
Share this Question
Share on Google+
1 Reply


code green
Expert 100+
P: 1,726
You can use CAST or CONVERT
Expand|Select|Wrap|Line Numbers
  1. SELECT CAST(varcharfield AS INT) FROM tablename
  2. SELECT CONVERT(INT, varcharfield ) FROM tablename
Sep 16 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.