Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Int into String (SQL Server/Win XP)

    Hello there.
    Please help me to convert integer into a string.
    I wrote a view in SQL Server and one Numeric of the fields must become string.
    thanks

    it is select statement
    Select field1, field2...
    So I have to do CAST or sometning else before the field2?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Int into String (SQL Server/Win XP)

    SQL Server has the STR function, with 3 syntac variations:

    STR(number)
    STR(number, length)
    STR(number, length, decimals)

    Example:

    SELECT STR([NumField], 6) AS TextField

    You can use CAST too:

    SELECT CAST([NumField] AS VARCHAR(6)) AS TextField

Posting Permissions

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