Omega Owners Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Please check the Forum Guidelines at the top of the Newbie section

Pages: [1]   Go Down

Author Topic: darn SQL  (Read 788 times)

0 Members and 1 Guest are viewing this topic.

tunnie

  • Get A Life!!
  • *****
  • Offline Offline
  • Gender: Male
  • Surrey
  • Posts: 37573
    • Zafira Tourer & BMW 435i
    • View Profile
darn SQL
« 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?
« Last Edit: 06 November 2008, 11:10:33 by tunnie »
Logged

Andy B

  • Get A Life!!
  • *****
  • Offline Offline
  • Gender: Male
  • Bury Lancs
  • Posts: 39778
    • ML350 TDM SmartRoadster
    • View Profile
Re: darn SQL
« Reply #1 on: 06 November 2008, 11:07:30 »

Does anyone else understand the question?  :-/  ;)  ;)  ;)
Logged

Phil B

  • Junior Member
  • **
  • Offline Offline
  • Gender: Male
  • South Wales
  • Posts: 237
    • View Profile
Re: darn SQL
« Reply #2 on: 06 November 2008, 11:17:44 »

Yep. Just looking through me scripts
Logged

Phil B

  • Junior Member
  • **
  • Offline Offline
  • Gender: Male
  • South Wales
  • Posts: 237
    • View Profile
Re: darn SQL
« Reply #3 on: 06 November 2008, 11:19:31 »

What data type is the column now?
« Last Edit: 06 November 2008, 11:19:44 by phil65412 »
Logged

Phil B

  • Junior Member
  • **
  • Offline Offline
  • Gender: Male
  • South Wales
  • Posts: 237
    • View Profile
Re: darn SQL
« Reply #4 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
Logged

cem_devecioglu

  • Guest
Re: darn SQL
« Reply #5 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
« Last Edit: 06 November 2008, 12:04:44 by cem_devecioglu »
Logged
Pages: [1]   Go Up
 

Page created in 0.014 seconds with 17 queries.