当前位置: 代码迷 >> Sql Server >> 存储过程,HELP!解决方案
  详细解决方案

存储过程,HELP!解决方案

热度:72   发布时间:2016-04-27 16:44:49.0
存储过程,HELP!!

create   proc   kinds
@acname   varchar(15),@aename   varchar(15),
@kcname   varchar(15),@kename   varchar(15)
as
insert   into   AllKinds   values(@acname,@aename);
create   table   @aename
(
KID   int   not   null   identity(1,1),
@kcname   varchar(15)   not   null,
@kename   varchar(15)   not   null
)
go
create   table   @kenane
(
DID   int   not   null   identity(1,1),
DCName   varchar(15)   not   null,
DImage   varchar(50),
DPrice   money   not   null
)
go
go

请问这个存储过程为什么不能让我用参数创建表和创建列?哪位好心的大虾能指点一二?多谢了!

------解决方案--------------------
create proc kinds @acname varchar(15),@aename varchar(15),
@kcname varchar(15),@kename varchar(15)
as
insert into AllKinds values(@acname,@aename)
exec( 'create table '[email protected]+ '
(
KID int not null identity(1,1),
@kcname varchar(15) not null,
@kename varchar(15) not null
) ')

exec( 'create table '[email protected]+ '
(
DID int not null identity(1,1),
DCName varchar(15) not null,
DImage varchar(50),
DPrice money not null
) ')
  相关解决方案