Author |
Topic |
oracle_corrgi
Yak Posting Veteran
98 Posts |
Posted - 2007-01-31 : 02:28:05
|
hihow can i convert smallint to varchardeclare @over smallint[rollover_txn] = CASE WHEN hh.[deint] & ' + CAST(varchar(5),@over)+ ' = ' + CAST(varchar(5),@over) + ' THEN 1 ELSE 0 END,krmm |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-31 : 02:30:09
|
[code]select convert(varchar(10), @over)[/code] KH |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-31 : 02:34:01
|
& is a BITWISE operator for AND, not concatenating. For this you use + sign.Peter LarssonHelsingborg, Sweden |
|
|
oracle_corrgi
Yak Posting Veteran
98 Posts |
Posted - 2007-01-31 : 03:15:36
|
Syntax error converting the varchar value ' + convert(varchar(10), @OVER)+ ' to a column of data type smallint.krmm |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-31 : 03:20:38
|
The string above is evaluated as "+4544+". The last plus sign is invalid.If you have no clue of dynamic sql, stay away from it!Read more here http://www.sommarskog.se/dynamic_sql.html about dynamic sql.Please do so!Peter LarssonHelsingborg, Sweden |
|
|
oracle_corrgi
Yak Posting Veteran
98 Posts |
Posted - 2007-01-31 : 03:31:53
|
can any one convert smallint to varchar for the above querykrmm |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-31 : 03:37:05
|
is that the complete query ? KH |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-31 : 03:43:15
|
Oracle_Corrgi, you are SO overcomplicating things.Learn to think T-SQL way, not C/C++ nor VB/VB.Net way!!!!Peter LarssonHelsingborg, Sweden |
|
|
oracle_corrgi
Yak Posting Veteran
98 Posts |
Posted - 2007-01-31 : 03:45:29
|
there r but i have one column to convert from smallint to varcharkrmm |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-31 : 03:48:12
|
"is that the complete query ?"And also you have irritating tendancy of not paying attention to what we are suggesting/asking here! Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-31 : 03:48:37
|
khtan told you how to do it! That is the proper way!The error occurs later because YOU DO NOT KNOW HOW TO PROPER USE DYNAMIC SQL!Peter LarssonHelsingborg, Sweden |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-31 : 04:10:27
|
Without the complete query, the best that i can help isuse convert(varchar(10), <your smallint value>) KH |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-01-31 : 05:10:25
|
uuu a circular reference khtan!!that's confusing Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-31 : 07:30:02
|
Very Sorry. I was confused by the OP on both threads KH |
|
|
|