日期:2014-05-18 浏览次数:20636 次
alter PROCEDURE cp_ttt ( @tableSponsor nvarchar(20) ) AS declare @sqlTableCreate nvarchar(1000) set @sqlTableCreate = N'Create table '+@tableSponsor+' (orgID nchar (10), orgRegSubject nchar (10), subjectTitle nvarchar (10), subjectSummary nvarchar (10))' execute @sqlTableCreate
------解决方案--------------------
@tableSponsor 是干啥了,没用?
@tableName 没定义.
CREATE PROCEDURE cp_ttt @tableSponsor nvarchar(20) AS begin declare @sqlTableCreate nvarchar(200) declare @tablename as varchar(10) set @tablename = '...' -- or set @tablename = @tableSponsor set @sqlTableCreate = N'Create table ' + @tableName + '(orgID nchar (10), orgRegSubject nchar (10), subjectTitle nvarchar (10), subjectSummary nvarchar (10) )' exec(@sqlTableCreate) end go
------解决方案--------------------
CREATE PROCEDURE cp_ttt
(
@tableSponsor nvarchar(20)
)
AS
declare @sqlTableCreate nvarchar(1000)
set @sqlTableCreate = N'Create table '+@tableSponsor+N'
(orgID nchar (10),
orgRegSubject nchar (10),
subjectTitle nvarchar (10),
subjectSummary nvarchar (10))'
execute sp_executesql @sqlTableCreate
GO
----
EXEC cp_ttt N'QQQ'
DROP TABLE QQQ
CREATE PROCEDURE cp_ttt ( @tableSponsor nvarchar(20) ) AS declare @sqlTableCreate nvarchar(1000) set @sqlTableCreate = N'Create table '+@tableSponsor+N' (orgID nchar (10), orgRegSubject nchar (10), subjectTitle nvarchar (10), subjectSummary nvarchar (10))' execute sp_executesql @sqlTableCreate GO ----测试存储过程 EXEC cp_ttt N'QQQ' DROP TABLE QQQ
------解决方案--------------------