Strangely :-), but Microsoft did it well:
http://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/
http://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/
Visual Studio 2008 also have such tool built in.
(However I am not sure about complex databases (like encrypted) yet...)
(However I am not sure about complex databases (like encrypted) yet...)