也可用exec exec('select top '+@topnumber+' * from mytable order by date')
exec('select top '+@topnumber+' * from mytable order by date') 如何返回结果数据?
CREATE PROCEDURE browse_house @location_sign bit, @number intAS set rowcount @number select location,housename,house_id,type,houseprice,housetypes from house where location_sign=@location_sign order by Submission_time desc set rowcount 0--最好写上这句话 GO
这是zjcxc(邹建) 大哥帮我解决问题提供另一种方法( ) .... AS declare @s Nvarchar(4000) set @s='select top '+cast(@number as varchar)+' location,housename,house_id,type,houseprice,housetypes from house where location_sign=@location_sign order by Submission_time desc' exec sp_executesql @s,N'@location_sign bit',@location_sign GO
exec('select top '+@topnumber+' * from mytable order by date')
如何返回结果数据?
@location_sign bit,
@number intAS
set rowcount @number
select location,housename,house_id,type,houseprice,housetypes
from house
where location_sign=@location_sign
order by Submission_time desc
set rowcount 0--最好写上这句话
GO
....
AS
declare @s Nvarchar(4000)
set @s='select top '+cast(@number as varchar)+' location,housename,house_id,type,houseprice,housetypes
from house
where location_sign=@location_sign
order by Submission_time desc'
exec sp_executesql @s,N'@location_sign bit',@location_sign
GO