Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tera SQL Update help

Status
Not open for further replies.

tmcrouse

Programmer
Dec 21, 2011
39
US
I have a very large table and one of the columns is a char(25) datatype. The problem is not all the data in this column has the same length yet when I query to get the distinct length, everything comes back 25. I need to alter some of the data and was trying to do it by the length. Here is an example of the data:

015M8000200
240010240

I need to take anything that has the trailing two zeros and remove those two zeros. I have tried all sorts of things like trying to trim the data so the actual field length is right but nothing has worked. Any advice?
 
I believe '[tt]char()[/tt]' is a fixed length string, thus your 25 for length regardless of contents.

I think you want '[tt]varchar()[/tt]'. This will vary in length with the data that's in the column.

 
I am a total idiot. I just completely forgot about a varchar because the original table had this as char in the database so I just thought I had to keep it the same when doing my query. Thanks so much You just saved me a lot of digging.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top