7
Answers

Help with while loop in sql server

Schleid Alex

Schleid Alex

4y
688
1
I have this query
 
Declare @Fnum nchar(5)
 
While (len(@Fnum)<5
Begin
 Set @Fnum += '0
End
 Print @Fnum
 
I am expecting 0000 as result
 
 But this is not happening, I only have 0 as result?
 
Can I have some help please?
 
Answers (7)