The Wrecking Bawl

Destructuring query language, one keyword at a time.


News


I imported a text file into SQL Server 2005 today and ended up with squares at the end of the last column.  Turns out the text file, despite being tab delimited, had a tab prior to CR/LF at the end of each row.  I was confused at first as to how to get rid of the squares, but then I figured it out.

SELECT ASCII(RIGHT(column,1)) FROM table  --gives 9, which is TAB in the ASCII table

UPDATE table SET column = REPLACE(column, CHAR(9), '')  --replaces tabs with nothing

 

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Comments

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: