if exists (select * from sysobjects where name='proc_Articles_page_call')
drop proc proc_Articles_page_call
gocreate proc proc_Articles_page_call
@Asid int,
@startIndex int,
@endIndex int
as
begin
declare @sql varchar(5000)
set @sql='with Temp as (SELECT cid = ROW_NUMBER() OVER (ORDER BY aid), * FROM Articles) select aid,Aname,Are,Afilepath,Aimage,Apoint,Avaliddate,Cnum from Temp  where Asid='+convert(char(5),@Asid)+' and cid between '+convert(char(5),@startIndex)+' and '+convert(char(5),@endIndex)+' order by aid'
exec(@sql)
end
goexec proc_Articles_page_call 100003,0,8放到sql变量中执行报错:关键字 'and' 附近有语法错误。(去了:Asid='+convert(char(5),@Asid)+' and 就正常)-----------
 分出来执行又正常
with Temp as (SELECT cid = ROW_NUMBER() OVER (ORDER BY aid), * FROM Articles)
 select aid,Aname,Are,Afilepath,Aimage,Apoint,Avaliddate,Cnum from Temp  where Asid=100003 and  cid between 1 and 10 order by aid
请大师帮助看一眼谢谢了