SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

oracle_corrgi
Yak Posting Veteran

India
98 Posts

Posted - 01/31/2007 :  02:28:05  Show Profile  Reply with Quote
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
17681 Posts

Posted - 01/31/2007 :  02:30:09  Show Profile  Reply with Quote
select convert(varchar(10), @over)



KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30281 Posts

Posted - 01/31/2007 :  02:34:01  Show Profile  Visit SwePeso's Homepage  Reply with Quote
& is a BITWISE operator for AND, not concatenating. For this you use + sign.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

India
98 Posts

Posted - 01/31/2007 :  03:15:36  Show Profile  Reply with Quote
Syntax error converting the varchar value ' + convert(varchar(10), @OVER)+ ' to a column of data type smallint.

krmm
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30281 Posts

Posted - 01/31/2007 :  03:16:38  Show Profile  Visit SwePeso's Homepage  Reply with Quote
See this topic http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=78351


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30281 Posts

Posted - 01/31/2007 :  03:20:38  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

India
98 Posts

Posted - 01/31/2007 :  03:31:53  Show Profile  Reply with Quote
can any one convert smallint to varchar for the above query

krmm
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17681 Posts

Posted - 01/31/2007 :  03:37:05  Show Profile  Reply with Quote
is that the complete query ?


KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30281 Posts

Posted - 01/31/2007 :  03:43:15  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
Go to Top of Page

oracle_corrgi
Yak Posting Veteran

India
98 Posts

Posted - 01/31/2007 :  03:45:29  Show Profile  Reply with Quote
there r but i have one column to convert from smallint to varchar

krmm
Go to Top of Page

harsh_athalye
Flowing Fount of Yak Knowledge

India
5581 Posts

Posted - 01/31/2007 :  03:48:12  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
"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"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30281 Posts

Posted - 01/31/2007 :  03:48:37  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17681 Posts

Posted - 01/31/2007 :  04:10:27  Show Profile  Reply with Quote
Without the complete query, the best that i can help is

use
convert(varchar(10), <your smallint value>)



KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17681 Posts

Posted - 01/31/2007 :  04:12:18  Show Profile  Reply with Quote
is this thread related to http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=78351 ?


KH

Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11751 Posts

Posted - 01/31/2007 :  05:10:25  Show Profile  Visit spirit1's Homepage  Reply with Quote
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
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17681 Posts

Posted - 01/31/2007 :  07:30:02  Show Profile  Reply with Quote
Very Sorry. I was confused by the OP on both threads


KH

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000