sql - Cast/Convert Text-Decimal -
i know bad practice way can due data migration column requirements.
i looking round up(ceil) or round down (floor) value in text feild.
i know fact either integers or decimals no worry bad data there.
update [dbo].[t01] set [2 37] = cast( floor(convert(decimal(10,5),(cast([2 37] varchar(10))))) text ) [2 37] '%.%'
my first attempt was:
update [dbo].[tomcat 19032013 01] set [2 37] = floor([2 37]) [2 37] '%.%'
long story short want able floor or ceil data in text field!
i using sql 2005 - developer edition
you should add columns conversion.
declare @t01 table([2 37] text, [2 37 floor] int, [2 37 ceiling] int) insert @t01 ([2 37]) values('1.5') insert @t01 ([2 37]) values('4.1') insert @t01 ([2 37]) values('5.9') update t set [2 37 floor]=floor(convert(decimal(8,2),(cast([2 37] varchar(10)))) ) , [2 37 ceiling] =ceiling(convert(decimal(8,2),(cast([2 37] varchar(10))))) @t01 t [2 37] '%.%' select * @t01
Comments
Post a Comment