Generate Script

  • 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

  • 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

  • Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply