From: Tom Cooper on
When you cast a float directly to varchar, it only keeps 6 digits by
default. You can keep more by using the CONVERT function with the style
parameter (see BOL), that will allow you to keep either 8 or 16 digits. But
it will return it in scientific notation (something like 7.8765430e+001). A
better choice is to cast the number to decimal (keeping however many decimal
digits you want) and then casting that result to varchar, e.g.,

CAST(CAST(i.lower_limit AS decimal(30, 12)) as varchar(30))

Tom

"Ben" <nospam(a)devdex.com> wrote in message
news:%23BFVXUj5KHA.348(a)TK2MSFTNGP02.phx.gbl...
>
>
> Table
> CREATE TABLE [dbo].[limit_def](
> [id] [int] NOT NULL,
> [lower_limit] [float] NOT NULL,
> [upper_limit] [float] NOT NULL,
> [timestamp] [timestamp] NULL,
> )
>
> Trigger code
>
> INSERT INTO log_table (
> change ,
> old_data ,
> new_data ,
> column_name ,
> table_name ,
> [key] )
>
> SELECT
> 'INSERT' ,
> NULL,
> CAST(i.lower_limit AS VARCHAR(30)),
> 'lower_limit' ,
> '[limit_def]' ,
> i.id
> FROM inserted i
>
> INSERT INTO log_table (
> change ,
> old_data ,
> new_data ,
> column_name ,
> table_name ,
> [key] )
>
> SELECT
> 'INSERT' ,
> NULL,
> CAST(i.upper_limit AS VARCHAR(30)),
> 'upper_limit' ,
> '[limit_def]' ,
> i.id
> FROM inserted i
>
>
> *** Sent via Developersdex http://www.developersdex.com ***

From: Ben on


Thanks Tom...that worked !!

Thanks to everyone for responding quickly.

*** Sent via Developersdex http://www.developersdex.com ***