I have two variables:
One of them is varchar, and one is int. I'm not sure how to write a while loop using casting to display the following: for example, if a while loop is 5, then the result should be Counter 1 Counter 2 Counter 3 Counter 4 Meter 5.
I have this code, but it does not work (cannot convert varchar to int), even when I cast, it does not work.
DECLARE @Name varchar (20) = 'Meter', @MeterNumber int = 1 WHILE (@MeterNumber < 5) BEGIN PRINT @Name + ' ' + @MeterNumber SET @MeterNumber = @MeterNumber + 1 END
sql sql-server
Shatha s
source share