I would like to automate script generation (in SSMS --> Tasks --> Generate Scripts) in SSMS 2008. I have read that SQL Server 2008 does not support Database Publishing Wizar
There a few ways of scripting all objects in database, but one of the easiest is to you the SMO tranfer class. Here's some PowerShell code to script out all objects:
add-type -AssemblyName "Microsoft.SqlServer.ConnectionInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
add-type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
add-type -AssemblyName "Microsoft.SqlServer.SMOExtended, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$sourceSrv = "$env:computername\sql2k8"
$sourceDb = "Northwind"
$server = new-object ("Microsoft.SqlServer.Management.Smo.Server") $sourceSrv
$db = $server.Databases[$sourceDb]
$transfer = new-object ("Microsoft.SqlServer.Management.Smo.Transfer") $db
$transfer.CopyAllObjects = $true
$transfer.DropDestinationObjectsFirst = $true
$transfer.CopySchema = $true
$transfer.Options.IncludeIfNotExists = $true
$transfer.ScriptTransfer()