Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Generate Script Expand / Collapse
Author
Message
Posted Friday, March 15, 2013 1:58 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, April 11, 2014 6:51 AM
Points: 1,371, Visits: 2,590
Hi All

Is there anyway I can use the below script to generate CREATE DATABASE commands?

select DB_NAME(smf.database_id)DatabaseName,type_desc,smf.name,physical_name,size ,sd.collation_name
from sys.master_files smf
inner join sys.databases sd
on db_name(smf.database_id) = sd.name
where db_name(smf.database_id)
not in ('master','model','tempdb','msdb')
order by name

Thanks
Post #1431394
Posted Friday, March 15, 2013 7:18 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 10:15 AM
Points: 1,782, Visits: 1,918
What might be a better way to do it is using the Object Explorer Details window in Management Studio. If you click on the Databases folder in Object Explorer, then from the top menu bar select View\Object Explorer Details, then a new tab pops up in SSMS. You can highlight all the databases you want to script, then right click and select Script Database As... Create To...
This will be much more detailed than trying to just use sys.databases and sys.master_files
Post #1431522
Posted Friday, March 15, 2013 7:56 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, April 11, 2014 6:51 AM
Points: 1,371, Visits: 2,590
Thanks
Post #1431544
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse