/********************************************************************************
格式化字符串
--------------------------------------------------------------------------------*/
create function PadLeft(@num varchar(16),@paddingChar char(1),@totalWidth int)
returns varchar(16) as
begin
declare @curStr varchar(16)
select @curStr = isnull(replicate(@paddingChar,@totalWidth - len(isnull(@num ,0))), '') + @num
return @curStr
END
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)