Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
youness_casa18
Starting Member
3 Posts |
Posted - 2011-04-27 : 07:59:07
|
| hello to all herehow can I create a database by using stored procedurethis procedure is like this:USE [master]GOcreate proc create_new_entreprise (@bd_name varchar(50))asbeginif not exists(select database_id from sys.databases where name =@bd_Name)beginexec('Create DATABASE'+' '+ @bd_Name)beginexec('USE'+' '+ @bd_Name)create table avion(av int primary key,avmarq varchar(30),avtype varchar(30),capacite int,loc varchar(30))create table pilote(pil int primary key,pilnom varchar(30),adr varchar(30))create table Vol(vol varchar(100) primary key,av int,pil int,vd varchar(30),va varchar(30),hd datetime,ha datetime,constraint fk_avion_vol foreign key (av) references avion (av),constraint fk_pilote_vol foreign key (pil) references pilote (pil))endendelseprint 'la base des données est déjà existante 'endif I try to excute this stored procedure i will have a empty database created and the tables wil created in the master database for more information i use sqlserver 2008 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-04-27 : 08:06:40
|
| Dupe, moved to correct forum: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=159920 |
 |
|
|
|
|
|
|
|