SQL Server 2008 中的 LPAD [英] LPAD in SQL Server 2008
本文介绍了SQL Server 2008 中的 LPAD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 SQL Server 2008 中看不到 LPAD
之类的函数.例如,如何将以下查询转换为 T-SQL?
I can't see a function like LPAD
in SQL Server 2008. For example how can I convert the following queries into T-SQL?
select LPAD(MY_VALUE,2,' ')) VALUE
FROM MY_TABLE
推荐答案
基本上用您打算选择的字符数填充它,然后右移字符串.
Basically pad it with the number of characters you are intending to select and then right the string.
Select right(replicate(' ',2) + YourFieldValue,2) from YourTable
你可以使用space函数代替replicate,space(number_of_spaces),replicate只允许你填充替代字符.
You can use the space function instead of replicate, space(number_of_spaces), replicate just allows you to pad with alternative characters.
这篇关于SQL Server 2008 中的 LPAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文