SQL 动态查询前多少个怎么弄? declare @t int=20 --这个@T的值是动态的select top (@t*0.2) * from test 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果是2005+直接select top (@t*0.2) * from test如果是2000exec('select top ' +@t*0.2+ ' from test') sql 2008 r2 报错Msg 1060, Level 15, State 1, Line 3The number of rows in the TOP clause must be an integer. --tryselect top cast((@t*0.2) as int) * from test Msg 102, Level 15, State 1, Line 4Incorrect syntax near 'cast'. declare @i intset @i=20set @i=@i*0.2select top (@i)* from sysobjects top (@i*n)--n不能用小数,必髯用整数 存储过程的问题!! 急急急,在线等待,希望大家帮忙 請問PowerDesigner中“包”是個什麼概念,怎樣理解 数据导入问题? 如何格式化货币类型数据 SELECT语句如何将一条记录拆成几条? 这样的功能存储过程如何实现? 数据库将一个表的某一列值覆盖到另外一个表的某一列值,为什么只把第一个数据传过去了呢? 一个非常简单的问题,请大家帮忙 Oracle8i(8.1.7)在Linux下的安装问题,急!!! 两个服务器的数据库实时传输数据,保持数据内容同步,哪位高手,救救菜鸟小弟阿 使用SQL参数进行insert操作一直报错 查询前50%的数据怎么弄?
直接
select top (@t*0.2) * from test如果是2000
exec('select top ' +@t*0.2+ ' from test')
sql 2008 r2 报错
Msg 1060, Level 15, State 1, Line 3
The number of rows in the TOP clause must be an integer.
select top cast((@t*0.2) as int) * from test
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'cast'.
set @i=20set @i=@i*0.2
select top (@i)* from sysobjects