某些時候
一
CREATE PROCEDURE p_Test
@TableName varchar(
AS
declare @SQLString nvarchar(
set @SQLString = N
EXECUTE sp_executesql @SQLString
CREATE PROCEDURE p_Test
@TableName varchar(
@UserID int
@UserName varchar(
AS
declare @SQLString nvarchar(
set @SQLString = N
@TableName +
N
EXECUTE sp_executesql @SQLString
N
@UserID
這也是 Microsoft SQL Server 的推薦做法
二
CREATE PROCEDURE p_Test
@TableName varchar(
AS
declare @SQLString nvarchar(
set @SQLString = N
EXEC(@SQLString)
以上兩種方法支持在運行時生成 Transact
From:http://tw.wingwit.com/Article/program/SQLServer/201311/22083.html