如下的存储过程 现在只能固定的取前4条记录,怎么改 能传入一个参数 动态的来决定取记录的条数?
CREATE PROCEDURE getHotTourList
(@tType int,@tTop int)
AS
SELECT top 4 * FROM cityTour
where
tType = @tType
and
tTop=@tTop
GO
CREATE PROCEDURE getHotTourList
(@tType int,@tTop int)
AS
SELECT top 4 * FROM cityTour
where
tType = @tType
and
tTop=@tTop
GO
ASexec 'SELECT top ' + @topV + ' * FROM cityTour where tType = ' + @tType + ' and tTop=' + @tTop
GO
(@tType int,@tTop int,@lineCount int)
ASdeclare @sql varchar(1024)set @sql = 'SELECT top ' + cast(@lineCount as varchar(128)) + ' * FROM cityTour
where
tType = ' + cast( @tType as varchar(128)) +
' and
tTop= ' + cast(@tTop as varchar(128)) exec @sql
(@tType int,@tTop int)
AS
SELECT top @nums * FROM cityTour
where
tType = @tType
and
tTop=@tTop
GO
CREATE PROCEDURE getHotTourList(@nums int=5)
(@tType int,@tTop int)
AS
SELECT top @nums * FROM cityTour
where
tType = @tType
and
tTop=@tTop
GO