Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gokula_k
Starting Member
3 Posts |
Posted - 2015-03-05 : 22:30:36
|
Hi,Problem:I want to set compatibility_level only when it is greater than 110.Solution:Select the compatibility level and if it is greater than 110, I alter database set compatibility level=110ISSUEIrrespective of IF Exist statement the alter database statement is executed all the time.Here is the sql statementIF EXISTS (SELECT * FROM sys.databases where compatibility_level >110 AND name='mydatabase')BEGINALTER DATABASE mydatabase SET COMPATIBILITY_LEVEL = 110ENDWhat is that I am missing here ??please support. |
|
seshurtz
Starting Member
7 Posts |
Posted - 2015-03-08 : 09:53:39
|
Hi gokula_k,I tested the script you provided and it appears to work as intended. Per my tests, it took into consideration the IF Exists statement.Is this the only script your using or is there more to it?Best,Steve Shurtz, MCPDatabase Administrator |
|
|
|
|
|