关于解决SQL语句select top 后面不能接变量的问题(sql 2000),采用动态的Sql语句来处理
 
ALTER proc [dbo].[sp_GetSubjectByTypeAndNum]
@type VarChar(50),
@num  Int 
as
declare @a int
set @a=@num 
declare @sql nvarchar(4000)
 
 
if @type='Single'
begin
--根据参数设置查询单选题Sql语句
--select top (@num) ID,Title,AnswerA,AnswerB,AnswerC,AnswerD from SingleProblem order by newid()
set @sql = 'select top '+ cast(@a as nvarchar(10)) + ' * from SingleProblem order by newid()' execute(@sql)
end

相关文章:

  • 2022-01-27
  • 2021-09-10
  • 2021-11-12
  • 2021-05-19
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2022-01-28
相关资源
相似解决方案