I am new to sql. I would like to ask what should I do when I will create a database using a stored procedure. I usually do this to create database: create databse db_mydatabase
a database name db_mydatabse will be created. Question: how will I able to create a database using stored procedure?
Use this
create procedure sp_create_db @name nvarchar(500)
as
begin
declare @sql nvarchar(max);
set @sql='CREATE DATABASE '+@name;
EXECUTE(@sql)
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.