CREATE PROCEDURE [InsertRoad]
@TableName[varchar](8),
@sTitle_p [varchar](50),
@sText_p [text]AS INSERT INTO [@TableName]
([sTitle],
[sText])
VALUES
(@sTitle_p,
@sText_p)
GO
================================================
想要在上面这个插入数据的存储过程中使用参数做表的名字,现在的写法是错误的,应该怎么改?
@TableName[varchar](8),
@sTitle_p [varchar](50),
@sText_p [text]AS INSERT INTO [@TableName]
([sTitle],
[sText])
VALUES
(@sTitle_p,
@sText_p)
GO
================================================
想要在上面这个插入数据的存储过程中使用参数做表的名字,现在的写法是错误的,应该怎么改?
set @sql='INSERT INTO ['+@TableName+']
([sTitle],
[sText])
VALUES
('+@sTitle_p+','+
@sText_p+')'EXECUTE SP_EXECUTESQL @SQL