select
SUBSTRING
(
CONVERT( varchar, CAST( 1234567 as money ), 1 )
, 1
, charindex
(
'.'
, CONVERT(varchar(20), CAST( 1234567 as money ), 1 )
, 2
) - 1
)
;
Use ROUND before you apply this if you do not intend to truncate... this is the formula using round before doing this:
ReplyDeleteSUBSTRING
(
CONVERT( varchar, CAST( ROUND( 123456, 0 ) as money ), 1 )
, 1
, charindex
(
'.'
, CONVERT(varchar(20), CAST( ROUND( 123456, 0 ) as money ), 1 )
, 2
) - 1
)