'Generate "CREATE DATABASE" script of existing database script using T-SQL

I am trying to generate create script of my existing database by querying DMV`s. I have found how to do that for tables and indexes, but cannot find an example for databases. Is there a way to that for databases ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source