Home  >  Article  >  Backend Development  >  How to replace some parameters in SQL statements with variables?_PHP Tutorial

How to replace some parameters in SQL statements with variables?_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:00:581009browse

You can use the exec method
declare @tempStr varchar(350)
select @tempStr='Update weekcount set [' convert(varchar,@week) ']=[' convert(varchar,@week) '] 1 where
userid=''' replace(@user,'''','''''') ''''
exec(@tempStr)
Note: Make exec unable to return the value of some variables , and the current variable value is invalid in the exec statement.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631206.htmlTechArticleYou can use the exec method declare @tempStr varchar(350) select @tempStr='Update weekcount set [' convert(varchar ,@week) ']=[' convert(varchar,@week) '] 1 where userid=''' replace(@user...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn