DBA

Scripting using SMO

I will be delivering a lightning talk at DataMinutes on June 7th on this topic. I thought it would help to write a synopsis of what am going to talking of on my blog post.

SMO – essentially stands for SQL Server Management Objects…this is a .net based scripting model Microsoft created to perform several SQL Server based tasks using scripts. It has been around since SQL Server 2005 and many people have written scripts using .net languages or powershell to accomplish various tasks. Using SMO is increasingly important in ‘Infrastructure as code’ world. Databases are a really important part of this infrastructure. Most of us find it easy and familiar to generate scripts using SSMS or Azure Data Studio and would prefer to keep doing it the same way. But, when you have a large code base – this can become problematic in many ways. People have varied SSMS settings that can allow room for non standard scripting. Scripting out what we create to add to our database repository becomes an additional task to do. Automating scripting using SMO helps to generate scripts that are uniform/standard in appearance and save the time lost in generating them as well.

SMO can accomplish a great many tasks within SQL server – those include backp/restore, creating agent jobs, changing server settings…on and on. I choose to focus my attention on just scripting SQL Server objects in this blog post and in my talk.

My script i will be using for this talk can be found here . My talk is at 11 am EST and the conference schedule is here. There are many awesome speakers..hope you will consider attending if you are reading this. Thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.