sql 使用存储过程传递列名或表名作为参数

原网址:

http://www.cnblogs.com/85538649/archive/2011/09/23/2186155.html

alter procedure Proc_UpdateDatetimeCounter
@businessNum nvarchar(200),--业务号
@column nvarchar(200),--列名
@value datetime--值
as
declare @sql nvarchar(max)
set @sql = N'update counter set '+quotename(@column)+'= @value1 where businessNum = @businessNum1'
exec sp_executesql @sql,
N'@value1 as datetime,@businessNum1 as nvarchar(200)',
@value1 = @value,
@businessNum1 = @businessNum

上一篇:selenium 使用随笔


下一篇:Mysql中表名作为参数的问题