Omega Owners Forum

Chat Area => General Discussion Area => Topic started by: tunnie on 06 November 2008, 11:04:55

Title: darn SQL
Post by: tunnie on 06 November 2008, 11:04:55
Does anyone know how to format a colum with SQL to remove a decimal point and reformat it to a numerical column rather than character?
Title: Re: darn SQL
Post by: Andy B on 06 November 2008, 11:07:30
Does anyone else understand the question?  :-/  ;)  ;)  ;)
Title: Re: darn SQL
Post by: Phil B on 06 November 2008, 11:17:44
Yep. Just looking through me scripts
Title: Re: darn SQL
Post by: Phil B on 06 November 2008, 11:19:31
What data type is the column now?
Title: Re: darn SQL
Post by: Phil B on 06 November 2008, 11:30:21
If it's already a text column, use
update dbo.table
set column2 = replace(column2,'.','')

replaces the . with nothing, then change the datatype in manager to a numeric one? Just tried it on a test table seemed to work ok
Title: Re: darn SQL
Post by: cem_devecioglu on 06 November 2008, 11:45:17
if for display,print purpose

select convert(decimal(25,0),field) from table

or

select cast(field as decimal) from table

this will cut the fraction part and still keep the numeric representation


or if you want to modify the column you must use

alter table TABLE alter column COLUMN  decimal(25,0) NOT NULL etc