top
Loading...
SQL語句中的一些參數如何用變量來代替?
可以采用exec方法
declare @tempStr varchar(350)
select @tempStr='Update weekcount set ['+convert(varchar,@week)+']=['+convert(varchar,@week)+']+1 where
userid='''+replace(@user,'''','''''')+''''
exec(@tempStr)
注意: 使exec不能返回一些變量的值,而且當前的變量值在exec的語句里無效.
北斗有巢氏 有巢氏北斗