/*
SELECT dbo.fn_PadLeft('8', '0', 6)
*/
create function fn_PadLeft(@num nvarchar(16),@paddingChar char(1),@totalWidth int)
returns nvarchar(16) as
begin
declare @curStr nvarchar(16)
select @curStr = isnull(replicate(@paddingChar,@totalWidth - len(isnull(@num ,0))), '') + @num
return @curStr
end

  

sql的padleft的更多相关文章

  1. sql函数PadLeft与PadRight代码实例

    1.PadLeft函数向已知字符串左边补充字符,使整个字符串到达指定长度 CREATE FUNCTION PadLeft ( ),/*原始字符*/ @TotalLength int,/*总长度*/ ) ...

  2. Sql实现PadLeft

    /******************************************************************************** 格式化字符串 ----------- ...

  3. SQL Server 实现类似C#中 PadLeft功能

    USE [Test] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO --@column 表示字段或者常量,@paddingChar 表示 补位 ...

  4. SQL SERVER格式化字符串位数,不足补零

    本文举例在SQLSERVER中将1格式化为001的方法: 1.方法一SQL语句执行如下: ,) as col 2.方法二SQL语句执行如下: ,) ,) as col 下面是C#代码实现方法: ; & ...

  5. 在Visual Studio 2013里使用 Microsoft SQL Server Compact Edition

    (1)下载SQLCE组件 https://www.microsoft.com/en-us/download/details.aspx?id=17876 (2)下载VS2013工具设计器 https:/ ...

  6. SQL Server UDF to pad a string

    http://www.mssqltips.com/sqlservertip/1738/sql-server-udf-to-pad-a-string/ declare @l varchar(50) se ...

  7. 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目

    最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...

  8. SQL Server 大数据搬迁之文件组备份还原实战

    一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搬迁步骤(Procedure) 搬迁脚本(SQL Codes) ...

  9. Sql Server系列:分区表操作

    1. 分区表简介 分区表在逻辑上是一个表,而物理上是多个表.从用户角度来看,分区表和普通表是一样的.使用分区表的主要目的是为改善大型表以及具有多个访问模式的表的可伸缩性和可管理性. 分区表是把数据按设 ...

随机推荐

  1. Autofac 控制反转

    class Program { static void Main(string[] args) { IContainer container = Init(); Go(container); Cons ...

  2. P1886 滑动窗口&&P1440 求m区间内的最小值

    声明:下面这两个题就不要暴力了,学一学单调队列吧 推荐博文:https://www.cnblogs.com/tham/p/8038828.html 单调队列入门题 P1440 求m区间内的最小值 题目 ...

  3. 【模板】dijkstra

    洛谷 4779 #include<cstdio> #include<cstring> #include<algorithm> #include<queue&g ...

  4. jdk8--十大新特性

    https://www.cnblogs.com/dennyzhangdd/p/6722445.html 一.十大特性 1.Lambda表达式 2.Stream函数式操作流元素集合 3.接口新增:默认方 ...

  5. Pillow 模块~Python图像处理

    什么是验证码? 验证码(CAPTCHA)是“Completely Automated Public Turing test to tell Computers and Humans Apart”(全自 ...

  6. RDS for MySQL查询缓存 (Query Cache) 的设置和使用

    https://help.aliyun.com/knowledge_detail/41717.html?spm=5176.7841698.2.11.aCvOXJ RDS for MySQL查询缓存 ( ...

  7. UVA 12683 Odd and Even Zeroes(数学—找规律)

    Time Limit: 1000 MS In mathematics, the factorial of a positive integer number n is written as n! an ...

  8. Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈

    D. Vasya and Chess   Vasya decided to learn to play chess. Classic chess doesn't seem interesting to ...

  9. CF799B T-shirt buying

    题目大意 有一些衣服,它们有价格.正面的颜色和反面的颜色.现有一群顾客按顺序来买存在某颜色且价格最低的衣服(不存在则不会买),求每个顾客花了多少钱. 思路 #include <cstdio> ...

  10. ConcurrentDictionary中的 TryRemove

    class A { internal int value; } ConcurrentDictionary<int, A> dic = new ConcurrentDictionary< ...