I'm looking for command line or scripted solutions to pull the DDL out of SQL Server 2005+ for all database objects: tables, stored procs, views, indices/indexes, constraints, etc. GUI tools are not of interest.
Preference is for built-in tools, since that would be the most comparable to Oracle's DBMS_METADATA stuff. Also, preference for a solution that is as simple as Oracle's for getting the DDL out - eg, a one liner:
SELECT DBMS_METADATA.GET_DDL('TABLE', 'MY_TABLE')
Note: Getting things out for procedures in SQL Server 2005 seems easy, but I can't find any references to something similar for other objects (like tables).
SELECT definition FROM Sys.sql_modules WHERE object_id = OBJECT_ID('MyProc')
Thanks in advance!