Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
T-SQL
»
Converting Integer to Text
Converting Integer to Text
Rate Topic
Display Mode
Topic Options
Author
Message
sdnkosi-735203
sdnkosi-735203
Posted Tuesday, May 13, 2008 4:54 AM
Forum Newbie
Group: General Forum Members
Last Login: Sunday, May 29, 2011 11:41 PM
Points: 8,
Visits: 58
Hi,
I am trying to convert an integer to text in a query using:
CASE WHEN [Extension]<'80' THEN '0' + CAST( Extension AS text(12)) ELSE [Extension] END AS Extn
but I get the following error:
'Explicit conversion from data type int to text is not allowed'
Any suggestions? I dont want to convert the Table
Post #499441
RyanRandall
RyanRandall
Posted Tuesday, May 13, 2008 5:07 AM
SSCommitted
Group: General Forum Members
Last Login: Tuesday, May 29, 2012 11:22 AM
Points: 1,755,
Visits: 4,652
Use varchar rather than text?
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Post #499450
sdnkosi-735203
sdnkosi-735203
Posted Tuesday, May 13, 2008 5:16 AM
Forum Newbie
Group: General Forum Members
Last Login: Sunday, May 29, 2011 11:41 PM
Points: 8,
Visits: 58
Hi,
The '0' is not added when I use varchar
Post #499454
Dharmalinga
Dharmalinga
Posted Tuesday, May 13, 2008 5:19 AM
Old Hand
Group: General Forum Members
Last Login: Monday, January 04, 2010 9:34 PM
Points: 373,
Visits: 64
hi
Try this
CASE WHEN [Extension]<'80' THEN '0' + CAST( Extension AS varchar(12)) ELSE [Extension] END AS Extn
Post #499457
Sergiy
Sergiy
Posted Tuesday, May 13, 2008 5:23 AM
SSCarpal Tunnel
Group: General Forum Members
Last Login: Today @ 8:01 AM
Points: 4,557,
Visits: 8,237
It must be
[Extension]<80
, not
[Extension]<'80'
.
Post #499460
sdnkosi-735203
sdnkosi-735203
Posted Tuesday, May 13, 2008 5:30 AM
Forum Newbie
Group: General Forum Members
Last Login: Sunday, May 29, 2011 11:41 PM
Points: 8,
Visits: 58
Still no luck
Post #499463
Dharmalinga
Dharmalinga
Posted Tuesday, May 13, 2008 5:46 AM
Old Hand
Group: General Forum Members
Last Login: Monday, January 04, 2010 9:34 PM
Points: 373,
Visits: 64
Try This
CASE WHEN [Extension]<80 THEN '0'+ CAST(Extension as VARCHAR(12)) ELSE CAST(Extension as VARCHAR(12)) END AS Extn
Post #499477
sdnkosi-735203
sdnkosi-735203
Posted Tuesday, May 13, 2008 5:56 AM
Forum Newbie
Group: General Forum Members
Last Login: Sunday, May 29, 2011 11:41 PM
Points: 8,
Visits: 58
Thank you all it works
Post #499487
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.