惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

博客园 - black263

因为数据库正在使用,所以无法获得对数据库的独占访问权---还原或删除数据库的解决方法 动态获取表每一列变更记录 获取表的列信息,包括列名,列数据类型,主键列.. SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问 sql server 客户端 登录名 痕迹删除 Sql Server2005恢复备份数据库问题-Error:3154 Slice a PSD Use a CSS Reset Learn Photoshop Google Code University Debug Javascript With Firebug – video tutorial CSS Compressor clean css css Optimiser CSS-Frameworks normalize.css google free web fonts 新公司报道第一天 C#连接数据库 模板类
sql 为数字加千分位
black263 · 2012-03-08 · via 博客园 - black263

原文地址:http://topic.csdn.net/u/20100317/15/04f1bf02-48be-4567-be7f-22c0ec5d2df9.html 13#,16#

create function dbo.GetFormatString(@dec decimal(28,15), @n int)
returns nvarchar(32) as
BEGIN
--原理,用parsename切成整数部分和小数部分(去除最后的0)
--用convert转money,自动带千分位
declare @re nvarchar(32)
declare @a nvarchar(32),@b nvarchar(32)

select @dec=round(@dec, case when @n<0 then 0 when @n=0 then 15 else @n end)
select @a=case when parsename(rtrim(@dec),2)='' then '0' else parsename(rtrim(@dec),2) end,
@b=parsename(rtrim(@dec),1)

select @a= parsename(convert(nvarchar(32), convert(money,@a),1),2)

select @b= stuff(reverse(@b),1,case when patindex('%[1-9]%',reverse(@b))>1 then patindex('%[1-9]%',reverse(@b))-1 else len(@b) end ,'' ) 

--小数部分加千分位
--select @b=reverse( parsename(convert(nvarchar(32), convert(money,@b),1),2))
--if @b='0' and @n>0
-- set @b=left('000,000,000,000,000', @n+(@n-1)/3)

--小数部分不加千分位
select @b=reverse(@b)
if @b='0' and @n>0
set @b=left('000000000000000', @n)

select @re= case when @n>=0 then @a+'.'+@b else @a end

if @b='0' and @n=0
set @re=@a

return @re
END