Remove SCHEMABINDING from a View in SQL Server

The purpose of schema binding a view is to ensure that the base tables referenced in the view cannot be modified in a way that would affect the view definition.

This is normally a good thing. After all, you don’t want someone coming along and dropping a table that your view depends on, do you?

But what if you need to make changes to one or more tables referenced by your view?

Continue reading

Return Operating System Version Info in SQL Server with the sys.dm_os_host_info Dynamic Management View

In SQL Server, you can use the sys.dm_os_host_info system dynamic management view to return information about the underlying operating system.

This view is similar to the sys.dm_os_windows_info view, except that sys.dm_os_host_info handles Linux systems as well as Windows, and it has more columns to differentiate between the two.

Continue reading

Use OBJECTPROPERTY() to Determine Whether an Object is a View in SQL Server

You can use the OBJECTPROPERTY() function in SQL Server to find out whether or not an object is a view.

This function accepts two parameters: the object ID, and the property for which you’re checking it for.

Therefore, you can pass the object ID as the first argument, and IsView as the second, and the function will return either a 1 or a 0 depending on whether or not it’s a view.

A return value of 1 means that it is a view, and a value of 0 means that it’s not.

Continue reading

Get View Information with the VIEWS Information Schema View in SQL Server

In SQL Server, you can use the Transact-SQL VIEWS system information schema view to return information about one or more views in the current database. It returns one row for views that can be accessed by the current user in the current database.

To use this view, specify the fully qualified name of INFORMATION_SCHEMA.VIEWS.

Continue reading