Get the Underlying Columns of a View Based on its Result Set

One of the great things about database views, is that they allow you to run complex queries without needing to know the underlying database schema.

Yes, it’s true that you need to know the underlying schema when you create the view, but you only need to do that once. Once you’ve created it, you can query that view all day long without needing to remember all the table and column names, etc.

Views typically combine data from multiple tables into a single, virtual table, which makes it kind of like a “black box”. As long as it works as designed, you don’t need to concern yourself with the hidden details.

But what if you do want to check a view for its underlying tables and columns?

Continue reading

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