April 12, 2016 at 10:29 am
Comments posted to this topic are about the item Pad length
April 28, 2016 at 6:31 am
I think I may have a use for this, thanks.
April 28, 2016 at 11:44 am
In my case, I needed to add the 'N' parameter for @UseFixedLength in the SELECT statement to avoid an error regarding invalid number of arguments. Also the result displayed for the 2nd Pad at Front example was not correct. The syntax I'm using for the SELECTS is as follows:
Pad at Front:
-------------
SELECT dbo.[KDT_FN_PADLEN]('11','0',7,'Y','N')
will result in
000000011
SELECT dbo.[KDT_FN_PADLEN]('11','0',7,'Y','Y')
will result in
0000011
Pad at Back:
-------------
SELECT dbo.[KDT_FN_PADLEN]('11','0',7,'N','N')
will result in
110000000
SELECT dbo.[KDT_FN_PADLEN]('11','0',7,'N','Y')
will result in
1100000
April 28, 2016 at 12:34 pm
Couldn't this have been simplified with the REPLICATE function?
SELECT REPLICATE(@CharsTobePaddedWith, @PadLenght) + @PaddedChar
Michael L John
If you assassinate a DBA, would you pull a trigger?
To properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
April 28, 2016 at 12:55 pm
April 28, 2016 at 2:24 pm
Awesome Thanks for the feedback:-)
I will definitively use the REPLICATE function, and rewrite the code.
There is always more than one way to skin a cat; but who skins cat's these days.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply