Monday, 12 February 2007

DatabasePropertyEX()

Database Properties - SQL 2000 vs SQL 2005
Using 'Read Only' as an example -

-- SQL 2000 -
select name from sysdatabases 
where databaseproperty(name,'isreadonly') = 1

-- SQL 2005 -
select name from sys.databases 
where databasepropertyEX(name,'Updateability') = 'READ_ONLY'

Note:
System Table SYSDATABASES still works in sql 2005, but the documentation states it will be deprecated in favour of SYS.DATABASES in a future version.
Function DATABASEPROPERTY still works in sql 2005, but the documentation states it will be deprecated in favour of DATABASEPROPERTYEX in a future version.

No comments: