how to add space to varchar columns in sql server

  • Hi

    I have a varchar column of length 30 characters....

    the values in the columns are less then 30 characters...

    when the value in the column is less then 30 characters then i want to pad the column value with spaces..how can i do this...please someone help me...

  • This was removed by the editor as SPAM

  • This will pad the varchar column v in table t to 30 characters:

    update t

    set v = v+space(30-len(v))

    where len(v) < 30

  • Why would you want to pad the column with spaces? It is better to keep the database lean and let your applications add any spaces if and when they need it while using this data.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply