1 USE [Test] 2 GO 3 SET ANSI_NULLS ON 4 GO 5 SET QUOTED_IDENTIFIER ON 6 GO 7 --@column 表示欄位或者常量,@paddingChar 表示 補位字元, @len 補位數量, @returnStr 8 create f... ...
1 USE [Test] 2 GO 3 SET ANSI_NULLS ON 4 GO 5 SET QUOTED_IDENTIFIER ON 6 GO 7 --@column 表示欄位或者常量,@paddingChar 表示 補位字元, @len 補位數量, @returnStr 8 create function [dbo].[PadLeft](@column varchar(16),@paddingChar char(1),@len int) 9 10 returns varchar(16) as 11 begin 12 declare @returnStr varchar(16) 13 select @returnStr = isnull(replicate(@paddingChar,@len - len(isnull(@column ,0))), '') + @column 14 return @returnStr 15 end