Skip to main content

Database Compatibility ...

Database Compatibility

This article would explain a practical way of using the system stored procedure "sp_dbcmptlevel".

Sp_dbcmptlevel :: Set the database compatibility level.

--------------------------------------------------------------------------------
By default,
for SQL Server 6.5 the comatibility level is 65,
for SQL Server 7.0 the comatibility level is 70,
for SQL Server 2000 the comatibility level is 80
--------------------------------------------------------------------------------


One can check their database compatibility level by executing the sp_dbcmptlevel system stored procedure.

Let me explain the way I made use of this system stored procedure in my previous company. We were having SQL Server 2k in our development environment but for a project our requirement were to use only SQL Server 6.5 (hmm quite old isn't it? when did you last heard about SQL Server 6.5 :) ). Its for sure that we can't purchase 6.5 version for this project alone. At that time sp_dbcmptlevel came to our rescue. We just executed the below query so that our database (get it right, its database level and NOT server level change) compatibility would be set to SQL Server 6.5

-- Replace Pubs with your actual database name
EXEC sp_dbcmptlevel 'pubs', 65

This way if by mistake you use any keywords which are not in version 6.5 it would throw an error. Once the project is done or anytime during the course of the project you can reset the compatibility level back to 80.

For testing purpose

1. EXEC sp_dbcmptlevel 'pubs'
This would give you the current compatibilty information for pubs database

2. EXEC sp_dbcmptlevel 'pubs', 65
This would set the compatibility to SQL Server 6.5 for Pubs database alone.

3. Select top 5* from authors
After executing point 2 if we run the above query it would throw an error because TOP keyword is not available in SQL Server 6.5

4. EXEC sp_dbcmptlevel 'pubs', 80
This would reset the compatibility of pubs database to SQL Server 2000. Now execute the
query mentioned in point 3 to see the top 5 records displayed.

For further reading:

I suggest you have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_da-di_5c8c.asp for more details on this topic.

Comments

Popular posts from this blog

Script table as - ALTER TO is greyed out - SQL SERVER

One of my office colleague recently asked me why we are not able to generate ALTER Table script from SSMS. If we right click on the table and choose "Script Table As"  ALTER To option would be disabled or Greyed out. Is it a bug? No it isn't a bug. ALTER To is there to be used for generating modified script of Stored Procedure, Functions, Views, Triggers etc., and NOT for Tables. For generating ALTER Table script there is an work around. Right click on the table, choose "Modify" and enter into the design mode. Make what ever changes you want to make and WITHOUT saving it right click anywhere on the top half of the window (above Column properties) and choose "Generate Change Script". Please be advised that SQL Server would drop actually create a new table with modifications, move the data from the old table into it and then drop the old table. Sounds simple but assume you have a very large table for which you want to do this! Then it woul

AWS fatal error: An error occurred (400) when calling the HeadObject operation: Bad Request

While using AWS and trying to copy a file from a S3 bucket to my EC2 instance ended up with this error message. Command Used: aws s3 cp s3://mybucketname/myfilename.html /var/www/html/ Error: fatal error: An error occurred (400) when calling the HeadObject operation: Bad Request The error goes off if we add the region information to the command statement. I am using Asia Pacific (Mumbai) so used ap-south-1 as the region name. Modified Command: aws s3 cp s3://mybucketname/myfilename.html /var/www/html/ --region ap-south-1

[Non Tech] Want to know the recipe for Omelette :)

Fed up with Bread - Jam and Curd Rice, today i wanted to eat Omelette. Interesting part is I wanted to cook it myself :) So in the first picture you see all the items which are needed for preparing an Omelette. When I had a closer look at the eggs I see that almost all the eggs are broken. But believe me when I bought it couple of days back it was in perfect condition! I was wondering whether the eggs have become rotten or pretty old to consume! I tried taking an egg and break it but couldn't break it at all :) Since I have kept in the freezer all the eggs have frozen and looked like a iron ball :) After trying for few minutes of trying i removed the shell of the egg and then kept that iron ball :) into a bowl and placed it within Oven. I heated it for 1 minute and checked. It melted only to a limit. So i just set it for another 2 minutes and checked it later. It has melted but the part of the egg white has become a Omelette :( I didn't leave it there. I took the bowl out of