存储过程中一个表的某个字段值为另一个表的表名该怎么写啊?
(select tablename from novel_topic where topicid=@topicid)
tablename的值为另一个表的表名
insert into 表名(topicid,chapter,path,length) values(@topicid,@chapter,@path,@length)
这个存储过程该怎么写啊?
declare @tb nvarchar(50),@sql nvarchar(2000)
select @tb=tablename from novel_topic where topicid=@topicid
set @sql='insert into '+@tb+'(topicid,chapter,path,length) values(@topicid,@chapter,@path,@length)'
exec sp_exeutesql @sql,N'@topicid int,@chapter nvarchar(20)....',@topicid,@chapter...