March 20, 2015 at 1:54 am
If exists (select fieldID from #tmploginfo where status <> 0
group by fieldID
having count(*) > 0)
begin
backup log rdb to disk = N'C:\rdb1.trn'
End
I want to iterate this query using a loop as many as 5 times max. I would like someone to help me out.
March 20, 2015 at 9:58 am
DECLARE @i tinyint = 1;
WHILE @i <= 5
BEGIN
If exists (select fieldID from #tmploginfo where status <> 0
group by fieldID
having count(*) > 0)
begin
backup log rdb to disk = N'C:\rdb1.trn'
End;
SET @i = @i+1;
END
-- Itzik Ben-Gan 2001
March 20, 2015 at 11:28 am
I hope this was for an example or homework and not for production.
March 21, 2015 at 2:09 pm
Unfortunately, I have to do this in production. However, I will be running this query when the production is down.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply