SQL SMO is a set of objects that can be used to manipulate SQL Server objects (servers, databases, tables… and so on) from.
Here is a piece of library code that will help you get started.
In order to use this class, you need the SMO object that get installed when you install the SQL SDK from the SQL setup.