我有一个数字类型的字段,想Select出来的结果以科学计数法显示,请问函数怎么写?
解决方案 »
- MS SQL 在学习版创建域约束
- sql2005数据库新建和删除表与存储过程
- 表的查询,合并,删除一起用的操作,怎么实现,感觉很难!
- sql语句优化之索引...一实例求解.100即然.即给分.
- 求一SQL语句
- 有没有sql函数可以截取字符串的! 比如420000000000 我想获得前两位 select XXX(ID) from TABLE 的得到 42
- 打sql server 2005 sp1 或sp2时总提示:未通过一个或多个实例的验证?
- 求一条SQL非常的急
- 用事务处理如何实现当从一个表中将某条记录删除时,将这条记录写入另一个备份表,同时写上删除者姓名?
- SQL中过程和视图在功能效果上有那些差别呢?
- 从A表查出数据,批量插入B表,能实现吗?
- sql server 2008问题
当从 smalldatetime 转换为字符数据时,包含秒或毫秒的样式将在这些位置上显示零。当从 datetime 或 smalldatetime 值进行转换时,可以通过使用适当的 char 或 varchar 数据类型长度来截断不需要的日期部分。下表显示了从 float 或 real 转换为字符数据时的 style 值。值 输出
0(默认值) 最大为 6 位数。根据需要使用科学记数法。
1 始终为 8 位值。始终使用科学记数法。
2 始终为 16 位值。始终使用科学记数法。
在下表中,左列表示从 money 或 smallmoney 转换为字符数据时的 style 值。值 输出
0(默认值) 小数点左侧每三位数字之间不以逗号分隔,小数点右侧取两位数,例如 4235.98。
1 小数点左侧每三位数字之间以逗号分隔,小数点右侧取两位数,例如 3,510.92。
2 小数点左侧每三位数字之间不以逗号分隔,小数点右侧取四位数,例如 4235.9819。
set @i=123456789
print 'test:'+convert(varchar(20),@i)这样就行了!
set @i=123456789
print 'test:'+convert(varchar(20),@i)
--test:1.23457e+008
declare @tb table(f1 varchar(50))
insert into @tb
select '-0.17035866907990846' union
select '-0.10411846905437244' union
select '-8.1290807532302473E-2'
select
cast(cast(cast(f1 as float)*100 as numeric(10,1)) as varchar)+'%' as result
from @tb--结果
result
-------------------------------
-10.4%
-17.0%
-8.1%(3 行受影响)
declare @i float
set @i=123456789
print 'test:'+convert(varchar(20),@i)
--test:1.23457e+008
select result = convert(float ,'901206161310000040271400',0)/*
result
-----------------------------------------------------
9.0120616131000006E+23(所影响的行数为 1 行)
*/
select result = cast(9.0120616131000006E+23 as decimal(24,0))/*
result
--------------------------
901206161310000060000000(所影响的行数为 1 行)*/
select @str='124232342143242342342.234234'
select @str
go
declare @str1 float
select @str1='124232342143242342342.234234'
select @str1
/*
---------------------------------------
124232342143242342342.23423400(1 行受影响)
----------------------
1.24232342143242E+20(1 行受影响)
*/
declare @str1 float
select @str1='124232342143242342342.234234'
select @str1
-----------------------------------------------------
1.2423234214324234E+20(所影响的行数为 1 行)