Pulled from the following link: http://www.karaszi.com/SQLServer/info_generate_script.asp
The SQLDMO API (DDL only)
The scrip generation code used by Enterprise Manager and Query Analyzer is available for us to use in the SQLDMO API. This means that you can write your own applets to generate scripts, and have the script looking exactly as you want. Below you find a simple VB example which generates script for all objects in the database:
Dim oSS As SQLDMO.SQLServer
Dim oDb As SQLDMO.Database
Dim oT As SQLDMO.Transfer
Dim sS As String
Sub Script()
Set oSS = New SQLDMO.SQLServer
Set oT = New SQLDMO.Transfer
oSS.Connect "server", "login", "password" 'Connect to the server
Set oDb = oSS.Databases("pubs") 'Use a DB
oT.CopyAllTables = True
oDb.ScriptTransfer oT, SQLDMOXfrFile_SingleFile, "C:\pubs.sql"
End Sub
You can also generate script using DMO per object. Just create an instance of the object and use the script method for that object.
Scptxfr.exe (DDL only)
This tool comes with SQL Server. See below URL for more information:
http://www.support.microsoft.com/?id=220163
They also listed some other products at that URL I listed at the top. You should probably review it in whole. I hope this helps.