Created
July 28, 2016 06:01
-
-
Save nordinrahman/077bea70bd0870e3c3d2dfa314e20c3e to your computer and use it in GitHub Desktop.
Set string to the right of the char variable in SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @COUNTER INT = 0; | |
DECLARE @PADDEDCOUNTER NCHAR(6) | |
WHILE @COUNTER < 100000 | |
BEGIN | |
SET @COUNTER = @COUNTER + 1 | |
DECLARE @COUNTERSTRING NVARCHAR(6) = CAST(@COUNTER AS NVARCHAR(6)); | |
SET @PADDEDCOUNTER = REPLICATE(N' ', 6-LEN(@COUNTERSTRING)) + @COUNTERSTRING | |
PRINT '"' + @PADDEDCOUNTER + '"' | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment