exec('select top '+@x*@y+' id from table')
解决方案 »
- sql report service 定时和有数据的时候发订阅
- 刚上任的部门经理问我的sql问题,急,要挣表现
- 我写的一个SQL语句太长,它要求最大128个字符,怎么解决这个问题?
- sql server update命令Timeout expried,备份下数据库就正常了
- 向 wufeng4552提问
- 连续几天大于0的查询怎么写?
- 简单问题:把两个字段相同表里的数据合并到一个视图里去怎样写SQL语句??
- 转置问题
- 大虾!!帮帮忙!!查询问题!!
- 触发器简单问题:如何删除多条记录时将删除的ID保存到另一个表里面100分!
- sql查询中如果外键不为空查询外键连接的其他表的数据,如果为空,显示一些默认的数据,如何查询?
- 这个语句该如何写,在线等
declare @y
set @x=2
set @y=2
exec('select top '+@x*@y +' id from table')
declare @y int
set @x=2
set @y=2
exec('select top '+@x*@y +' id from table')服务器: 消息 170,级别 15,状态 1,行 5
第 5 行: '*' 附近有语法错误。
declare @x int
declare @y int
set @x=2
set @y=2
exec('select top '+cast(@x*@y as char)+' id from table')
declare @y int
set @x=2
set @y=2
exec('select top '+cast(@x*@y as char)+' id from table')服务器: 消息 170,级别 15,状态 1,行 5
第 5 行: 'cast' 附近有语法错误。
declare @y int
declare @z varchar(10)
set @x=2
set @y=2
set @z=cast(@x*@y as varchar(10))
exec('select top '+@z+' id from table')--测试通过
为什么不直接用set @z=(@x*@y)????
@y int,
@xy varchar(10),
@sql varchar(100)
set @x=1
set @y=2
set @xy=convert(varchar(10),@x*@y)
set @sql='select top '+@xy+' * from krs'
exec(@sql)