SMO (SQL Management Objects) in SQL Server 2005 replaces SQL-DMO that was present in the earlier versions of SQL Server. SMO provides a better performance using lazy loading and has a better coverage for database objects. You can generate scripts for objects in basic and advanced modes. Michiel Wories has more on scripting using SMO.
The nice thing about new managed APIs in SQL Server 2005 is that SQL Server Management Studio interacts with the database using exactly the same libraries so you can make sure you can manage your databases in the same way you would do it using Management Studio.
As an example, the following piece of code iterates through the databases in SQL2005 instance and enables auto update statistics for any non-system database if it is currently disabled.
(a reference to Microsoft.SqlServer.Smo and Microsoft.SqlServer.ConnectionInfo is required).
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
.
.
private void updateStatistics()
{
Server myServer = new Server(@"localhost\SQL2005");
foreach (Database database in myServer.Databases)
{
if (!database.IsSystemObject && !database.AutoUpdateStatisticsEnabled)
{
database.DatabaseOptions.AutoUpdateStatistics = true;
database.Alter();
}
}