declare @sql varchar(200)
set @sql='select top'+cast(@IntTop as varchar)+' * from news where NewsKindId='+cast(@NewsKindId as varchar)
ExEC(@sql)
写存储过程并没有提示from附近有语法错误,但浏览中查看时却提示说from附近有语法错误,请高手们帮忙解决一下
top后面应该接数值类型,因此不应该将@IntTop转化成varchar。直接写成:declare @sql varchar(200) set @sql='select top'+@IntTop+' * from news where NewsKindId='+cast(@NewsKindId as varchar) ExEC(@sql) 试试看。