From the course: PowerShell for SQL Server Administration

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating views

Creating views - PowerShell Tutorial

From the course: PowerShell for SQL Server Administration

Start my 1-month free trial

Creating views

- [Instructor] So another object type we can create either through SMO in PowerShell or through TSQL is going to be views. So like tables, like databases, we have a couple of different ways we can create these objects. We can use SQLPS and SMO and use the New-Object cmdlet to actually create new objects. Or we can use the native T-SQL in order to run that directly in PowerShell. So let's go ahead and take a look at what those options are going to actually look like when it comes to actually creating the code. So this gets a little bit different than it looked before 'cause in the previous file when we were actually going to create a table we were instantiating through a lot of operators to actually create the view. Here it's a little bit different just because of the way views need to be done. So first thing we do, we cd into our test three database. We create an object with the object type of SMO.View. Set our…

Contents