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

WBOY
Release: 2016-07-13 17:00:58
Original
1010 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template