Tag Archive: SMO

Using SMO Transfer Class to Script Database Objects

I’ve spent some time trying to get the SMO Transfer class to bend to my will. I want to script out all objects of a certain type or a select list of objects. As we will see a moment this was a bit a of challenge and it wasn’t until I had given up ,…

The T-SQL Hammer

The over-reliance on a familiar tool is best described with the quote, “if all you have is a hammer, everything looks like nail” and for database professionals this means using or sometimes misusing T-SQL. Whenever database administrators are presented with a scripting problem they instinctively reach for good-old-familiar T-SQL.  And why not? In many cases…

Hello SMO (F#) World!

Reading The F# Survival Guide has motivated me to write my version of an F# “Hello World!” utility. What I mean by that is to write something simple that I’ve written in other programming languages as a learning exercise. In my world of databases I use SMO (pronounced smoh or S-M-O). One of the easiest things…

Powershell SQL Server Backup/Restore

I posted a script on Poshcode for doing backups and restores of SQL Server databases using SMO. The script is adapted from SQL Server Powershell Extensions functions of the same name. SMO 9.0 (2005) and 10.0 (2008) have slightly different methods and properties at times. For the most part there is very little difference, however for…

Powershell + SMO Error Handling Tips

Allen White posted a helpful post on SMO error handling with Powershell. Actually the same concept equally applies to SMO coded in any other .NET language. SMO uses an error object’s InnerException which can be several layers deep and you must traverse the nested InnerExceptions to get to the detailed error message. Related to Allen’s post,…