SQL 2008 setting compatibility level - sql

When I try to add a data-base in SQL Server 2008 (Right clicking on Databases folder->New Database) the only compatibility options given to me in the options tab are 70, 80, and 90.
However, I require the use of the DATE object, which doesn't work unless I set the compatibility level to 100.
I've tried using
exec sp_dbcmptlevel mydb, 100;
GO
However, I get the following error:
Valid values of the database compatibility level are 60, 65, 70, 80, or 90.
What I am missing here?

From your description, it certainly appears that the database is a SQL Server 2005 database, not SQL Server 2008. Does it have a "100.something" next to the server name? If not, it's not SQL Server 2008.
Are you using SQL Server 2008 Management Studio, or an earlier version?

Leave it blank. Compatibility level is there to allow you to set the compatibility to a lower version of the database (if you need to).

Have you by chance tried the following?
ALTER DATABASE [DatabaseName] SET COMPATIBILITY_LEVEL = 100

Try in SQL Server Management Studio: right click on database -> properties -> options, and choose compatibility level

Related

How convert SQL Server 2008 R2 database to SQL Server 2012 completely

How open my SQLServer2008R2 database in SQLServer2012. When I open the database these problems happened:
I can't edit and open tables because this error show:
Invalid prefix and suffix characters.
When I want design tables this error show:
The backend version isn't supported to design database diagram or tables.
When you detach and attach database, the compatibility level of old database is maintained. It is one of the limitations of detach and attach method.
Reference
If we attach a database having a higher version, SQL Server maintains
the database compatibility. We can change the compatibility level once
the database is online
Once you change the compatibility level to suit SQL Server 2012, you can use the new features of the SQL Server 2012.
Read more on upgrading database
ALTER DATABASE DatabaseName SET COMPATIBILITY_LEVEL = 110
GO

How to check SQL Server 2008 script will work properly on SQL Server 2005

Is there a way (a tool) to check that a SQL Server 2008 script will run on SQL Server 2005?
Open up SQL Management studio, rt mouse click on the database name, select properties, select option, set compatability level. Test. A far as is known, when the compatabailty level is set to a (lower) level, functionality is disabled and errors raised entirely in line with the selected level. MS are a bit relctant to comit http://msdn.microsoft.com/en-gb/library/bb510680.aspx but in practice I've not found any issues. You can of course install an instance of the 2005 build and bulk insert for a really thorough check.
You can use SQL Fiddle for SQL Server 2008
At the left top you can select the RDMS

Intellisense not working in SQL Server Management studio. what could be reason?

I have been working on SSMS 2008 for last 1 month, I have enabled intellisense
Not sure why but it just does not work. what could be reason?
We had the same problem with Intellisense not working, in both SSMS version 17.9 and 18.0 and 18.1, when using Azure SQL DB, on accounts that were not dbmanager.
The suggestion from #sundar helps, even if it reports an error
Msg 40508, Level 16, State 1, Line 1
USE statement is not supported to switch between databases. Use a new connection to connect to a different database.

SQL Azure Compatibility Level

I thought that SQL Azure was built on top of SQL Server 2012, but the compatibility level when you create a new database is 100 (SQL Server 2008's compatibility level), not 110.
SELECT compatibility_level FROM sys.databases WHERE name = 'Test';
I tried changing it to 110 using the two methods that I am aware of:
ALTER DATABASE Test SET COMPATIBILITY_LEVEL = 110;
--> Incorrect syntax near 'SET'.
EXEC sp_dbcmptlevel 'Test', 110;
--> Could not find stored procedure 'sp_dbcmptlevel'.
The reason this is an issue for me is because SQL 2008 doesn't support geography shapes which cross hemispheres, so if you zoom out a map to see the world and try to store the bounds of the map it will fail. Pretty silly right?
I thought that this would not be an issue in SQL Azure, because it has been fixed in SQL Server 2012, but when I try to create a shape that crosses hemispheres I get the following error:
Microsoft.SqlServer.Types.GLArgumentException: 24205: The specified input does not represent a valid geography instance because it exceeds a single hemisphere. Each geography instance must fit inside a single hemisphere. A common reason for this error is that a polygon has the wrong ring orientation. To create a larger than hemisphere geography instance, upgrade the version of SQL Server and change the database compatibility level to at least 110.
So it is telling me to change the compatibility level, like it knows that this has been fixed already, but I can't figure out how to do that in SQL Azure. Anyone have a suggestion of something to try? Or let me know if it just is not possible right now?
It is hard to say if the current SQL Azure is based on SQL Server 2008 or 2012 however November 2011 update adds lots of new feature to it from SQL Server 2008 and 2012. More Info on Database Engine Versions:
Updated Engine Version: This release updates the underlying SQL Azure database engine version from 11.0.1477.26 to 11.0.1750.34 as it is rolled out across data centers.
The following link talks about what is and what not supported with SQL Azure comparative to SQL Server 2008 and SQL Server 2008 R2:
http://msdn.microsoft.com/en-us/library/windowsazure/ff394115
The following links adds more info about what new Programmability Enhancements are added in SQL Azure from SQL Server 2012:
http://msdn.microsoft.com/en-us/library/windowsazure/hh987034.aspx
UPDATE: August 2015
Azure Sql Database V12 has a default compatibility level of 120 with possibility to go up to 130 or down using ALTER DATABASE SET COMPATIBILITY_LEVEL syntax.

SqlServer 2000 compatibility

The developer environment db server is SqlServer 2005 (developer edition)
Is there any way to make sure my SQL Queries will run in SqlServer 2000?
This database is set to Compatibility level "SQL Server 2000 (80)" but some queries that run without problems in the development system can not run in the Test Server (SqlServer).
(The problems seems to be in subqueries)
Compatibility levels are designed to work the opposite way - to allow an older version of T-SQL code to work without modifications on a newer version of SQL Server. The changes typically involve T-SQL syntax and reserved words, and it's possible to use SQL Server 2005 features such as INCLUDED columns in indexes on a database in Compatibility Level 80. However, you can't use 2005 T-SQL features such as CROSS APPLY.
Your best option is to develop/test all your code against a SQL Server 2000 instance. Note that you can use 2005's Management Studio to connect to the SQL Server 2000 instance, so you don't have to go backwards with regards to tools.
Problem solved:
In correlated subqueries you have to (in SQL2000) explicitly define the external field.
SQL2005:
SELECT * FROM Loans WHERE EXISTS (SELECT * FROM Collaterals WHERE COLLATERAL_LOAN=LOAN_NUMBER)
SQL2000:
SELECT * FROM Loans WHERE EXISTS (SELECT * FROM Collaterals WHERE COLLATERAL_LOAN=Loans.LOAN_NUMBER)
You should always explicitly define all fields, otherwise you will not get an error when you make a mistake and write
SELECT * FROM Loans WHERE EXISTS (SELECT * FROM Collaterals WHERE LOAN_NUMBER=Loans.LOAN_NUMBER)
If Collaterals-table doesn't have column LOAN_NUMBER, the Loans-table is used instead.