use tempdb if object_id('tb') is not null drop table tb go create table tb([a] float) insert into tb select 1 union all select 1.0 union all select 1.2 union all select 1.6 union all select 1.22 go select cast(a as int) as a from tb /* a ----------- 1 1 1 1 1 */
恩。直接cast(数字 as int)
declare @A decimal(9,3) declare @B decimal(11,3)set @A = 89.087 set @B = 789.876select cast(@B-@A as int) -- /*700 */
if object_id('tb') is not null drop table tb
go
create table tb([a] float)
insert into tb
select 1 union all
select 1.0 union all
select 1.2 union all
select 1.6 union all
select 1.22
go
select cast(a as int) as a from tb
/*
a
-----------
1
1
1
1
1
*/
declare @B decimal(11,3)set @A = 89.087
set @B = 789.876select cast(@B-@A as int)
--
/*700
*/
select floor(12.956)-floor(1.333)
select floor(12.956-1.333)
/*
---------------------------------------
11(1 行受影响)
---------------------------------------
11(1 行受影响)*/
select floor(12.956-1.333)
select cast((12.956-1.333) as int)
/*
---------------------------------------
11(1 行受影响)
---------------------------------------
11(1 行受影响)---------------------------------------
11(1 行受影响)*/