Home > SQL Server > DatabaseProperty and DatabasePropertyEX

DatabaseProperty and DatabasePropertyEX


DatabaseProperty() : This function gives us the property value of the given database and property name as the function arguments. This function returns an integer as an output value. It may return the null value if we don’t have permission to the object or incorrect argument value. This function will be removed from the future version of SQL Server.

These are the valid database properties for this function

pic1Example

select Databaseproperty(db_name(1), ‘Version’)
select Databaseproperty(db_name(1), ‘isansinulldefault’)

DatabasePropertyEX() : This function gives us the property value of the given database and property name as the function arguments. This function returns a sql_variant type output value. It may return the null value if we don’t have permission to the object or incorrect argument value. This function will be removed from the future version of SQL Server. We should use this function instead DatabaseProperty() in our new application development.

Valid database property names for this function are

pic2Example

select DatabasepropertyEX(db_name(1), ‘Updateability’)
select DatabasepropertyEX(db_name(1), ‘UserAccess’)

These functions return a single property value at a time. If this function returns 0 then it means false and if it returns 1 then it means true or output values are self explained. Null represents the error in the argument or user does not have permission to the objects.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: