str = "update photos set zid="&ZID&" where pid in (select top 10 pid from photos where userid='"&user&"' and aid='"&aid&"' order by pid ) "response.write "*****" & str & "****"try to run the statement between "***" in the query analyzer to make sure it works as is
解决方案 »
- 帮忙看看这个语句那个地方有问题,谢谢
- 这个sql语句难倒我N天了,求救高手
- 怎么一次可以创建多条存储过程
- "在SQL创建语句中加上identity,表示自动编号"具体是怎样实现的
- 求教一个SELECT语句的简单用法
- sql数据库没有备份,被老备份恢复,请问能否取消老备份恢复操作,还原到恢复操作之前的状态?
- 月转季度
- 关于查询多表数据库问题(更改)
- 谁能提供一些自动生成sql查询语句的资料?类似sql server管理器查询界面那样,可以根据用户操作自动生成sql语句。
- 关于2张表修改数据同步
- 谁能给我讲讲inner join 是什么意思?用这个和用试图什么区别?
- 运行一条查询语句(对一个表),1分30秒;同样语句在另一台机器上只需3秒?
应该是更新符合userid和aid条件记录的前10条的所有数据。
@quantity int
asupdate photos set zid=100016 where pid in (select top @quantity pid from photos where userid='xielk' and aid='78' order by pid )
GO
语法检查通不过,它告诉我在top 后面的@quantity后面有语法错误,换数字就可以为什么不能这样写?
@quantity int
as
declare @sql nvarchar(4000)
set @sql='update photos set zid=100016 where pid in (select top '+cast(@quantity as varchar)+' pid from photos where userid=''xielk'' and aid=''78'' order by pid '
exec(@sql)
GO
@quantity int
as
exec('update photos set zid=100016 where pid in (select top '+@quantity+' pid from photos where userid=''xielk'' and aid=''78'' order by pid ')
GO
如果这样写,查询分析器会在@userid这里报错,我不知道这种写法怎么来区别数值和字符,再帮看看
exec('update photos set zid='+@Zid+' where pid in (select top '+@quantity+' pid from photos where userid='+@userid+' and aid='+@aid+' order by pid )')
在ASP语句里面先把数据转为字符型再传过来
go
declare @str varchar(100)
declare @sql nvarchar(4000)
select @str='1'
select @sql='update jobs set job_desc='+@str
exec (@sql)select * from jobs
select @sql='update photos set zid='+''''+@Zid+''''+' where pid in (select top '+@quantity+' pid from photos where userid='+''''+@userid+''''+' and aid='+''''+@aid+''''+' order by pid )'
2个‘’等于一个‘