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

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
Jina AI
Jina AI
雷峰网
雷峰网
月光博客
月光博客
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
B
Blog RSS Feed
美团技术团队
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
Security Latest
Security Latest
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
A
Arctic Wolf
Latest news
Latest news
Attack and Defense Labs
Attack and Defense Labs
I
Intezer
F
Fortinet All Blogs
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
Help Net Security
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 【当耐特】
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
Stack Overflow Blog
Stack Overflow Blog
Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
H
Help Net Security
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tenable Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog

博客园 - 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