When my app starts up I want to ensure that the database compatibility level has been set to 90. I know about sp_dbcmptlevel, but that only seems to work in an interactive session; the documentation says it can't be used in a stored procedure, and that appears to be true. Does anyone know how I could read the database compatibility level in a stored proc?
You can query the catalog views below to get the database compatibility level information:
-- SQL Server 2005 only
select compatibility_level from sys.databases where name = @.dbname
-- SQL70/2000/2005
select cmptlevel from master.dbo.sysdatabases where name = @.dbname
|||That's it. Thanks!
No comments:
Post a Comment