| Author |
Topic  |
|
|
oracle_corrgi
Yak Posting Veteran
India
98 Posts |
Posted - 01/31/2007 : 02:28:05
|
hi how can i convert smallint to varchar declare @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)
Singapore
16746 Posts |
Posted - 01/31/2007 : 02:30:09
|
select convert(varchar(10), @over)
KH
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 01/31/2007 : 02:34:01
|
& is a BITWISE operator for AND, not concatenating. For this you use + sign.
Peter Larsson Helsingborg, Sweden |
 |
|
|
oracle_corrgi
Yak Posting Veteran
India
98 Posts |
Posted - 01/31/2007 : 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
Sweden
29138 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 01/31/2007 : 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 Larsson Helsingborg, Sweden |
Edited by - SwePeso on 01/31/2007 03:21:27 |
 |
|
|
oracle_corrgi
Yak Posting Veteran
India
98 Posts |
Posted - 01/31/2007 : 03:31:53
|
can any one convert smallint to varchar for the above query
krmm |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 01/31/2007 : 03:37:05
|
is that the complete query ?
KH
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 01/31/2007 : 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 Larsson Helsingborg, Sweden |
Edited by - SwePeso on 01/31/2007 03:52:06 |
 |
|
|
oracle_corrgi
Yak Posting Veteran
India
98 Posts |
Posted - 01/31/2007 : 03:45:29
|
there r but i have one column to convert from smallint to varchar
krmm |
 |
|
|
harsh_athalye
Flowing Fount of Yak Knowledge
India
5509 Posts |
Posted - 01/31/2007 : 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 Athalye India. "The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 01/31/2007 : 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 Larsson Helsingborg, Sweden |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 01/31/2007 : 04:10:27
|
Without the complete query, the best that i can help is
use
convert(varchar(10), <your smallint value>)
KH
|
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
|
|
spirit1
Cybernetic Yak Master
Slovenia
11741 Posts |
Posted - 01/31/2007 : 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)
Singapore
16746 Posts |
Posted - 01/31/2007 : 07:30:02
|
Very Sorry. I was confused by the OP on both threads 
KH
|
 |
|
| |
Topic  |
|