October 22, 2012 at 6:48 am
Hi,
I am confused about belwo statment.
Although, Recovery model of TempDB can’t be changed but Why this simple IF condition fails?
IF 1 <> 1
BEGIN
ALTER DATABASE TempDB SET RECOVERY SIMPLE WITH NO_WAIT
END
please help me
October 22, 2012 at 6:50 am
Because the validity of the statement is checked before it's actually run.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 22, 2012 at 7:05 am
If you really want, you can code it like that:
IF 1 <> 1
BEGIN
EXEC ('ALTER DATABASE TempDB SET RECOVERY SIMPLE WITH NO_WAIT')
END
October 22, 2012 at 7:32 am
@Gila
Then why this code be executed successfully.
IF 1 <> 1
BEGIN
BACKUP DATABASE tempdb TO DISK ='D:\tempdb.bak'
END
October 22, 2012 at 8:22 am
I would guess because backup statements are checked for validity when they run. Two very different statements, you shouldn't be surprised they act differently (one's DDL the other maintenance)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 22, 2012 at 11:33 pm
Thanks Gila
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply