Home > php教程 > php手册 > SQL语句中的一些参数如何用变量来代替?

SQL语句中的一些参数如何用变量来代替?

WBOY
Release: 2016-06-13 10:04:49
Original
1224 people have browsed it

可以采用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的语句里无效.

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template