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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Manipulation

Status
Not open for further replies.

Dutt

Programmer
Aug 20, 2001
33
US
I have a table called table1. It has a column called column1 and the datatype is numberic.

Each record in that column has a trailing ".00000". I'm trying to build an update statment that will trim off the .00000.

Any help would be great!

Justin
 
If the data type is numeric, you won't be able to get the data stored without the specified number of decimal places. You would need to actually change the data type of the column to do that.

If you want the data displayed without the DPs then use:

Code:
SELECT CONVERT(int, col1) FROM t1

--James
 
Try this
select convert(decimal(7,0),colname) from table
 
I get the error when I try both examples:

Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.


Is there a way to do it in a Update Statement?

Cheers,
Justin
 
Check your data.

Do you have NULLs?
Do you have empty data fields (spaces)?
Do you have any characters that are not numbers?

Any of those can cause the convert to fail.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top