http://www.sqlservercentral.com/blogs/sqldbauk/2011/09/29/sql-bits-training-day/

Printed 2014/07/30 01:28PM

SQL Bits Training Day

By Gethyn Ellis, 2011/09/29

By David Postlethwaite

Just spent a day with Allen White, a SQL MVP from Ohio, USA learning about automating and managing SQL Server using PowerShell

PowerShell is ubiquitous in Windows now and can be used to view and manage any part of the Windows systems, it uses the .NET framework which, for me who has written plenty of c#,  made it much easier to understand. One of the things I liked about PowerShell was the way that objects like the registry and SQL Server can be browsed just like a disk drive.

The real winner, not just for PowerShell but for .NET as well, is SQL Server Management Objects or SMO, a whole class of functions that can be used to interrogate SQL Server. I hadn’t come across this before but I could see so many ways that I could use it for retrieving information and managing SQL Server. An example was “how would you find all varchar fields in all databases in several instances and change them to varchar(max). A nightmare with t-sql but with SMO quite easy.

We also saw example scripts for retrieving performance data into a database.

For support and diagnostics of your own systems its definitely the way to go , much more flexible than t-sql and much better for quick ad-hoc queries than trying to use .NET. And there are loads of example scripts on-line.

Can’t wait to give it a go back in the office



Copyright © 2002-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.