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.
| Author |
Topic |
|
snarty
Starting Member
2 Posts |
Posted - 2008-03-12 : 20:55:48
|
| I'm trying to CAST an integer to a varchar and I keep getting e+006 in my result set. The reason I need to do this is so that I can combine 2 columns to return a string.Here is my table:incomeBracket | lowIncome(int) | highIncome(int)-----------------------------------------------1 1000001 50000002 5000001 10000000Here is my query:SELECT CAST(incomeLow AS varchar) + ' - ' + CAST(incomeHigh AS varchar) AS incomeRangeFROM IncomeBracket_CurrencyHow can I get my result to look like this:1000001 - 50000005000001 - 10000000Instead of what it is returning now:1e+006 - 5e+0065e+006 - 1e+007The query works fine for values that have a character length of 6 and less.Thanks in advance. |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2008-03-12 : 21:13:30
|
| I can't reproduce it but this is really something you should do at the front-end. |
 |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2008-03-12 : 21:16:06
|
Select cast(1000001 as varchar(8)) + '-' + Cast(5000000 as varchar(8))Specify a length for the varchar. Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
snarty
Starting Member
2 Posts |
Posted - 2008-03-12 : 23:12:47
|
| oh sorry I have fixed this problem. On revising my table design I found that the data type was a float and not an int. It works now!My bad! |
 |
|
|
|
|
|