Aug 6, 2003 #1 john0532 Programmer Jul 2, 2002 27 US I'm new to Transact-SQL. I've got a number in a varchar field that I need to get the numeric value of. How do I go about this? Thanks
I'm new to Transact-SQL. I've got a number in a varchar field that I need to get the numeric value of. How do I go about this? Thanks
Aug 6, 2003 #2 SQLBill MIS May 29, 2001 7,777 US It's always best to give an example of some data, but here goes: SELECT CONVERT(int, datafield) Replace datafield with whatever your varchar datafield name is. This will ONLY work if there are numbers and only numbers in the field. -SQLBill Upvote 0 Downvote
It's always best to give an example of some data, but here goes: SELECT CONVERT(int, datafield) Replace datafield with whatever your varchar datafield name is. This will ONLY work if there are numbers and only numbers in the field. -SQLBill
Aug 6, 2003 Thread starter #3 john0532 Programmer Jul 2, 2002 27 US Great. Now how do I put the numerical value into a variable of type int? Upvote 0 Downvote
Aug 6, 2003 #4 SQLBill MIS May 29, 2001 7,777 US Just like I showed you. Let's say this is your VARCHAR column with numeric data: COL 1 534652 7381704 721 793948 9866 What I gave you will take that data and return it as an integer. If that's NOT what you wanted, please explain it futher and provide sample data and what you want done with it. -SQLBill Upvote 0 Downvote
Just like I showed you. Let's say this is your VARCHAR column with numeric data: COL 1 534652 7381704 721 793948 9866 What I gave you will take that data and return it as an integer. If that's NOT what you wanted, please explain it futher and provide sample data and what you want done with it. -SQLBill
Aug 6, 2003 Thread starter #5 john0532 Programmer Jul 2, 2002 27 US Thanks again. Your statement "returns it as an integer" answered my question Upvote 0 Downvote