Unfortunately SQL Server 2008 and earlier do not have this feature so we could create a query of the form sig
SELECT ISNULL (REPLICATE ('0 ', 5 - len (ISNULL ('2', 0))),'') + '2 '
Which
return
00002 How It Works
replicate feature a character doubles the number of times you indicate,
apply the formula to determine the size of replication, this would
replication = total length of the field-current length of the string once OBTAIN
the Replication simply add the string of characters
deals
Now if we could often make a function
CREATE FUNCTION [dbo]. [PadLeft]
(@ sequence varchar (16),
@ character char (1), @ length int
)
RETURNS varchar (16) AS DECLARE @
BEGIN
curSeq varchar (16) SELECT @
curSeq = ISNULL (REPLICATE (@ character, @ length - len (ISNULL (@ Sequence, 0))),'') + @ Sequence
END RETURN @ curSeq
(@ sequence varchar (16),
@ character char (1), @ length int
)
RETURNS varchar (16) AS DECLARE @
BEGIN
curSeq varchar (16) SELECT @
curSeq = ISNULL (REPLICATE (@ character, @ length - len (ISNULL (@ Sequence, 0))),'') + @ Sequence
END RETURN @ curSeq
can test for the sig.
a SELECT
dbo.PadLeft ('9 ', '0', 5) SELECT
dbo.PadLeft ('10 ', '0', 5)
- Useful for pages