| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

03-19-09, 04:35
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 5
|
|
|
Data Type Conversion
|
|
Hi All,
I want to know how I can convert int datatype to varchar how I do the same.
query is : select convert(DesignationCode,varchar(200) from employee;
above query is showing error
But when i used char(200) instead of varchar it is working fine.
Kindly guide me how to use varchar in datatype conversion.
with regards
Girish Kardam
|
|

03-19-09, 04:46
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
try CAST(DesignationCode AS CHAR)
|
|

03-19-09, 04:49
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
|
|
Has the missing paren got anything to do with the error?
Code:
SELECT Convert(DesignationCode, varchar(200)
FROM employee;
|
|

03-19-09, 04:54
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
check da manual, george
correct syntax, let me show u it 
|
|

03-19-09, 05:23
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
Oops
Code:
Convert(varchar(200), some_field)
|
|

03-19-09, 05:49
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
oops is right
what forum are you in? did you check da mysql manual???
|
|

03-19-09, 06:24
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
dev.mysql will never load from this location, so no, I did not.
|
|

03-19-09, 06:27
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 5
|
|
Hi r394,
I had gone through the mysql manual after that only i posted my query in the forum. As i didn't find any solution for converting int datatype to varchar.
with regards
Girish Kardam
|
|

03-19-09, 07:20
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
Quote:
|
Originally Posted by gvee
dev.mysql will never load from this location, so no, I did not.
|
oh, i see
well, that's okay then
just keep posting stuff from the sql server manual, then

|
|

03-19-09, 07:37
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
okay, to be somewhat more helpful...
next time you're on a computer that can access dev.mysql.com, george, download one of the CHM files, and copy it to a floppy (or a usb memory stick or whatever) and take that with you
the CHM is a ~lot~ easier to search and browse than going to dev.mysql.com anyway

|
|

03-19-09, 11:06
|
|
vaguely human
|
|
Join Date: Jun 2007
Location: London
Posts: 2,519
|
|
I should also point out that MySQL will automatically convert numbers to characters when required ie select concat( 1234,"a") will produce "1234a".
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|