读书人

就10分了跪求存储过程,该如何处理

发布时间: 2012-03-06 20:47:55 作者: rapoo

就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

读书人网 >SQL Server

热点推荐