Views and Simplification

SQL Server 2005, SQL Server 2008, SQL Server 2012, SQL Server 2014, SQL Server 2016, TSQL
I've been getting lots of questions on views lately. Must be something in the water. Because SQL Server allows you to treat a view as if it was a table, lots of people pretty much assume that it is a table since they get to treat it that way. The thing is, a view is not a table. It's a query. Let's explore this just a little bit. Here's a relatively straight forward view: [crayon-5a6cfdc1ee223938762740/] I can query this view like this: [crayon-5a6cfdc1ee233441351100/] The resulting execution plan looks like this: You don't even need to expand it for what I'm about to show. If we modify the query against our view as follows: Again, you can expand these, but you don't need to. Notice, the first plan had four tables…
Read More