Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2009
    Posts
    5

    Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try CAST(DesignationCode AS CHAR)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Has the missing paren got anything to do with the error?
    Code:
    SELECT Convert(DesignationCode, varchar(200)
    FROM   employee;
    George
    Home | Blog

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    check da manual, george

    correct syntax, let me show u it
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Oops
    Code:
    Convert(varchar(200), some_field)
    George
    Home | Blog

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    oops is right

    what forum are you in? did you check da mysql manual???
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    dev.mysql will never load from this location, so no, I did not.
    George
    Home | Blog

  8. #8
    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

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  10. #10
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  11. #11
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    I should also point out that MySQL will automatically convert numbers to characters when required ie select concat( 1234,"a") will produce "1234a".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •