you need to do this using
Code:
EXEC sp_GenerateScript @server = 'Server_Name',
@uname = 'User_Name',
@pwd = 'Password',
@dbname = 'Database_Name',
@filename = 'c:\File_Name.sql'
and you can find all the details here
http://www.mssqlcity.com/Articles/Ge...eAutSP.htm three quarters down the page
Example: generate script
Jaime E. Maccou