declare @tmpid int =-1 print @tmpid select @tmpid=id from dbo.ActivityPlayers where id=@id print @tmpid if @tmpid =-1 begin insert into dbo.ActivityPlayers (id) values(@id) end print @gamename set @gamename='game2' print @gamename update dbo.ActivityPlayers set @gamename=@content where id=@id
如以上代码,申明部分未贴
想以@gamename 代替字段,但是不知道用什么格式sql可以识别?有网友说 用&&包起来或者“”包起来都试过了,米用。
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
[{$xxxxxxxxxxx$}]
找到方法了 ,只要再定义一个varchar类型的变量,然后将要操作的语句赋值给它,再去调用这个变量。
附上代码参考,注意本来是varchar的变量前后要加上转义的单引号,还有int类型的要转成varchar