| Author |
Topic |
|
dirwin26
Yak Posting Veteran
81 Posts |
Posted - 2005-09-27 : 08:22:40
|
| Can anyone please help on this one. When I try to convert data type varchar to bigint I receive the below error. Here's the T-SQL:SELECT sum(revturn) as 'ttm' from #res2Where TheDate = @NextQDate SELECT cast ('ttm' as bigint)Here's what I get in Query Analyzer:Server: Msg 8114, Level 16, State 5, Procedure rev, Line 82Error converting data type varchar to bigint.Any help would be appreciated,Cheers. |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2005-09-27 : 08:41:46
|
Your second query is trying to cast the literal string 'ttm' as bigint. Try this:SELECT sum(cast(revturn as bigint)) as 'ttm' from #res2Where TheDate = @NextQDate Mark |
 |
|
|
dirwin26
Yak Posting Veteran
81 Posts |
Posted - 2005-09-27 : 09:06:48
|
| That worked great! So the same thing for the next line, i'm trying to divide the 'ttm'into a new variable and I am getting the same message. So I have to do the conversion on @Shares:select ('ttm' / @Shares) as 'per'I still get :Error converting data type varchar to bigint.but I declared @Shares as BIGINT in my procedure so It would seem i'm using like data. What gives?Thanks again! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-27 : 09:22:04
|
| Try thisSelect ttm/(cast(@Shares as bigint)) as 'per' from yourTableMadhivananFailing to plan is Planning to fail |
 |
|
|
dirwin26
Yak Posting Veteran
81 Posts |
Posted - 2005-09-27 : 09:34:22
|
| I had to use '' around ttm.Select 'ttm'/(cast(@Shares as bigint)) as 'per' from #res2and i'm still getting:Server: Msg 8114, Level 16, State 5, Procedure rev, Line 83Error converting data type varchar to bigint.Any ideas? Cheers.... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-27 : 09:38:40
|
| What do you mean by 'ttm'?MadhivananFailing to plan is Planning to fail |
 |
|
|
dirwin26
Yak Posting Veteran
81 Posts |
Posted - 2005-09-27 : 09:41:36
|
| I have named the computation as 'ttm' so I can reference it though asp. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-27 : 09:45:15
|
| I think you need thisSELECT sum(cast(revturn as bigint))/cast(@Shares as bigint) as 'per' from #res2Where TheDate = @NextQDate MadhivananFailing to plan is Planning to fail |
 |
|
|
dirwin26
Yak Posting Veteran
81 Posts |
Posted - 2005-09-27 : 09:48:46
|
| Thanks a bunch. It worked great...Dave |
 |
|
|
|