Results 1 to 5 of 5

Thread: Force column width

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893

    Force column width

    Hi,

    I need to copy data from tables.

    I'm trying with this:

    select cod_art as itemid, ;
    alltrim(des_art) + " " + alltrim(des_art1) as itemname, ;
    tipo_articolo as itemgroupid, ;
    cod_umisu as bomunitid;
    from articoli;
    into cursor cur_articoli

    des_art is C(50)
    des_art1 is C(50)

    on the target table, itemname is C(100)
    on the cursor, itemname is C(19)... the lenght of the first des_art..
    Can I force the lenght of the column?

    thanks
    Fabio

  2. #2
    Junior Member
    Join Date
    Jun 2019
    Posts
    4
    I guess

    left(alltrim(des_art) + " " + alltrim(des_art1)+space(100),100) as itemname

    would do the job.

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,863
    Blog Entries
    18
    Use rpad()
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    thanks to all..

    on the while I've foud also
    select cast(cod_art as Char(20)) as itemid, ;
    cast(rtrim(des_art) + " " + rtrim(des_art1) as char(60)) as itemname, ;
    cast(tipo_articolo as char(10)) as itemgroupid, ;
    cast(cod_umisu as char(10)) as bomunitid;
    from articoli;
    into cursor cur_articoli

  5. #5
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,893
    but rpad() is better.

    the cast function give strange data result.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us