|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, March 25, 2013 1:06 AM
Points: 9,
Visits: 37
|
|
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
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 4:18 PM
Points: 38,062,
Visits: 30,359
|
|
Because the validity of the statement is checked before it's actually run.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 2:08 AM
Points: 2,596,
Visits: 4,506
|
|
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
_____________________________________________ "The only true wisdom is in knowing you know nothing" "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!" (So many miracle inventions provided by MS to us...)
How to post your question to get the best and quick help
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 8:15 AM
Points: 12,
Visits: 162
|
|
@Gila Then why this code be executed successfully.
IF 1 <> 1 BEGIN BACKUP DATABASE tempdb TO DISK ='D:\tempdb.bak' END
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 4:18 PM
Points: 38,062,
Visits: 30,359
|
|
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 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, March 25, 2013 1:06 AM
Points: 9,
Visits: 37
|
|
|
|
|