Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2009
    Posts
    79

    Unanswered: Trim a column in a sql database table.

    Hi All,

    Can we have a query in SQL server 2005 which will trim all the records of a particular column in a sql database table. If yes, can any one provide me an example.

    Thanks a lot for your help in advance.

  2. #2
    Join Date
    Sep 2009
    Posts
    79

    Trim a column in a sql database table

    Please help.

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The concept of "trim" doesn't apply well to table columns, it is ambiguous. The columns are already "trimmed" in most cases.

    What exactly do you want to see happen with the column?

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  4. #4
    Join Date
    Sep 2009
    Posts
    79

    Trim a column in a sql database table

    Hi,

    Actually I am importing some data from a text file into excel and then I am cleaning it up in excel so there are certain columns where in few of the records after the text there are some spaces which remain as it is when I import excel file in my sql server database table using import export wizard. What I want to do is to skip the excel step and directly import text file into sql server database table and then run some query to trim such columns if there is some records which have spaces after the text.



    Thanks a lot for your help in advance.

  5. #5
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    do you mean eliminate spaces between characters? You have several postings and in all of them you do not provide a very good description of what you have and what you would like. Try providing examples as in my data looks like this 'dajkfh' and I want to change it to look like this 'fsklgj'
    Dave

  6. #6
    Join Date
    Sep 2009
    Posts
    79

    Trim a column in a sql database table. Reply to Thread

    Hi,

    My data looks like 'abcd ' or ' abcd' and I want to trim it and make it like this 'abcd'. This is what i require.

    Thanks a lot for your help in advance.

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    select ltrim(rtrim([YourData]))

    And did you bother looking up "trim" in the online reference resources for sql server?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  8. #8
    Join Date
    Sep 2009
    Posts
    79

    Trim a column in a sql database table.

    Thanks a lot it's working now.

Posting Permissions

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