Home Forums SQL Server 2005 Development Is there any way to create the database using stored procedure which includes design RE: Is there any way to create the database using stored procedure which includes design

  • In its simplest form:

    CREATE PROC dbo.createnewdb (@dbname SYSNAME)

    AS

    BEGIN

    DECLARE @sql NVARCHAR(MAX) = N'CREATE DATABASE ' + QUOTENAME(@dbname);

    EXEC(@sql);

    END

    GO

    EXEC dbo.createnewdb N'newdb';

    There are too many considerations to list here before creating a stored procedure like this and allowing folks to call it but something like I showed should get you started.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato