use master go IF db_id('tagl')IS NOT NULL drop database tagl go create database tagl go use tagl go create table kcb ( 书号 varchar(20), 书名 varchar(34), 作者 varchar(8), 出版日期 datetime, 定价 decimal(4,2), 库存数量 int )
filename='e:\sql\tagl_log.ldf',你电脑里 E盘里有 sql文件夹吗?
学校机器的SQL版本和你电脑不一致?
use master go --drop database tagl go create database tagl /*on ( name=tagl, filename='e:\sql\tagl.mdf', size=10, filegrowth=2 ) log on ( name=tagl_log, filename='e:\sql\tagl_log.ldf', size=5, filegrowth=1 )*/ go use tagl go create table kcb ( 书号 varchar(20), 书名 varchar(34), 作者 varchar(8), 出版日期 datetime, 定价 decimal(4,2), 库存数量 int ) 因为你数据库里本来就没有tagl这个数据库 所以会报错 use master go IF db_id('tagl')IS NOT NULL drop database tagl
go create database tagl /*on ( name=tagl, filename='e:\sql\tagl.mdf', size=10, filegrowth=2 ) log on ( name=tagl_log, filename='e:\sql\tagl_log.ldf', size=5, filegrowth=1 )*/ go use tagl go create table kcb ( 书号 varchar(20), 书名 varchar(34), 作者 varchar(8), 出版日期 datetime, 定价 decimal(4,2), 库存数量 int ) 这里加了判断 如果存在才会删除 tagl这个数据库 所以就没问题了
go
IF db_id('tagl')IS NOT NULL
drop database tagl
go
create database tagl go
use tagl
go
create table kcb
(
书号 varchar(20),
书名 varchar(34),
作者 varchar(8),
出版日期 datetime,
定价 decimal(4,2),
库存数量 int
)
use master
go
--drop database tagl
go
create database tagl
/*on
(
name=tagl,
filename='e:\sql\tagl.mdf',
size=10,
filegrowth=2
)
log on
(
name=tagl_log,
filename='e:\sql\tagl_log.ldf',
size=5,
filegrowth=1
)*/
go
use tagl
go
create table kcb
(
书号 varchar(20),
书名 varchar(34),
作者 varchar(8),
出版日期 datetime,
定价 decimal(4,2),
库存数量 int
) 因为你数据库里本来就没有tagl这个数据库
所以会报错 use master
go
IF db_id('tagl')IS NOT NULL
drop database tagl
go
create database tagl
/*on
(
name=tagl,
filename='e:\sql\tagl.mdf',
size=10,
filegrowth=2
)
log on
(
name=tagl_log,
filename='e:\sql\tagl_log.ldf',
size=5,
filegrowth=1
)*/
go
use tagl
go
create table kcb
(
书号 varchar(20),
书名 varchar(34),
作者 varchar(8),
出版日期 datetime,
定价 decimal(4,2),
库存数量 int
)
这里加了判断 如果存在才会删除 tagl这个数据库 所以就没问题了