Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

why this condition fail (IF 1 <> 1) Expand / Collapse
Author
Message
Posted Monday, October 22, 2012 6:48 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 2:51 AM
Points: 9, Visits: 46
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
Post #1375397
Posted Monday, October 22, 2012 6:50 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 11:52 AM
Points: 41,530, Visits: 34,446
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

Post #1375398
Posted Monday, October 22, 2012 7:05 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, April 03, 2014 10:10 AM
Points: 2,792, Visits: 4,874
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
Post #1375405
Posted Monday, October 22, 2012 7:32 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, April 14, 2014 2:04 AM
Points: 12, Visits: 196
@Gila
Then why this code be executed successfully.

IF 1 <> 1
BEGIN
BACKUP DATABASE tempdb TO DISK ='D:\tempdb.bak'
END
Post #1375422
Posted Monday, October 22, 2012 8:22 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 11:52 AM
Points: 41,530, Visits: 34,446
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

Post #1375450
Posted Monday, October 22, 2012 11:33 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 2:51 AM
Points: 9, Visits: 46
Thanks Gila
Post #1375836
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse