Welcome to Day 17 of my “A Month of PowerShell” series. This series will use the series landing page on this blog at //blog.waynesheffield.com/wayne/a-month-of-powershell/. Please refer to this page to see all of the posts in this series, and to quickly go to them.

We’ve spent several days working with tables, but that’s not all that is in a database. Continuing the mini-series of objects compiled with T-SQL code, today we will work with views.

Creating a view

That was pretty simple. Does anybody out there have any questions? Okay, let’s move on.

Altering a view

Perhaps you noticed that the view’s definition is performing a select *. Seeing this gets the fangs coming out, fingernails in the clawing position, and the hair rising on the back of my neck. Okay, not really, but it is a practice generally considered to be bad. Let’s change this view to specify the columns.

Dropping a view

If you want to drop the view, after verifying that the view does exist, simply call its drop method. So from the above script for the alter, change this section:

To: