Hello.
Trying something like this. I am trying to set a @variable to 1 so I can update some records to FOLDER1. At the end of my script I would like to set the @variable to + 1 so I can set the next records to FOLDER2, etc.
How can I set a starting @variable and then add + 1 to it? When the script loops around the @variable is reset to 1.
Any ideas? I'm sure there is a way to do this.
Trying something like this. I am trying to set a @variable to 1 so I can update some records to FOLDER1. At the end of my script I would like to set the @variable to + 1 so I can set the next records to FOLDER2, etc.
How can I set a starting @variable and then add + 1 to it? When the script loops around the @variable is reset to 1.
Code:
while (select count(id) from mytable where folder is null) > 0
begin
declare @foldernumber int
set @foldernumber = 1
update mytable set folder = 'FOLDER' + convert(varchar(5), @foldernumber)
set @foldernumber = @foldernumber + 1
end
Any ideas? I'm sure there is a way to do this.