日期:2014-05-19  浏览次数:20499 次

就10分了,跪求存储过程
create   proc   ansList
@NC   nvarchar(12),
@nbz   int,
@topnum   int
as
exec   ( 'select   top   '+@topnum+ '   a1,a2,a3,a4   from   An   where   NC   =   @NC   and   newsbz=@nbz   order   by   ndate   desc ')
go

这个存储过程为什么运行不了

------解决方案--------------------
create proc ansList
@NC nvarchar(12),
@nbz int,
@topnum int
as
Begin
Declare@S Varchar(1000)
Select @S = 'select top '+ Cast(@topnum As Varchar) + ' a1,a2,a3,a4 from An where NC = ' ' ' + @NC + ' ' ' and newsbz= ' + Cast(@nbz As Varchar) + ' order by ndate desc '
exec(@S)
End
go