create procedure p
@news_types varchar(8000) --新闻类别,逗号分割
asselect id
,title
,stime
from news
where charindex(','+convert(varchar,news_type)+',',','+@news_types+',')>0
order by id desc
@news_types varchar(8000) --新闻类别,逗号分割
asselect id
,title
,stime
from news
where charindex(','+convert(varchar,news_type)+',',','+@news_types+',')>0
order by id desc
是这样吗?
如果我要读第一类的新闻:
rs.open "P '1'",1
是这样吗?
@news_types varchar(8000) --新闻类别,逗号分割
asselect id
,title
,stime
from news
where charindex(','+convert(varchar,news_type)+',',','+@news_types+',')>0
order by id desc调用:
rs.open "P_NEWS '"&news_type&"'",conn,1,1
提示where charindex 之类有问题 啊
rs.open "P_NEWS '"&cstr(news_type)&"'",conn,1,1
如果我想读第一类的新闻,就这样:
rs.open "P_NEWS '1'",conn,1,1
如果我想读第二类的新闻,就这样:
rs.open "P_NEWS '2'",conn,1,1
.....
就是这样的哦,那应该怎么写啊,麻烦您了哦
@news_type int, --新闻类别
@area varchar(20) --区域
asif @area=''
set @area=nullselect id
,title
,stime
from news
where news_type=@news_type
and
area=isnull(@area,area)
order by id descgo
调用:
rs.open "P_NEWS 1,'"&session("area")&"'",conn,1,1
rs.open "P_NEWS 2,'"&session("area")&"'",conn,1,1
比如
调用:
rs.open "P_NEWS 1,'"&session("area")&"','条数'",conn,1,1
@news_type int, --新闻类别
@area varchar(20), --区域
@rows int --显示条数
asif @area=''
set @area=null
if @rows is null
set @rows=0set rowcount @rows
select id
,title
,stime
from news
where news_type=@news_type
and
area=isnull(@area,area)
order by id descset rowcount 0
go
调用:
rs.open "P_NEWS 1,'"&session("area")&"',10",conn,1,1 --前10条
rs.open "P_NEWS 2,'"&session("area")&"',20",conn,1,1 --前20条
rs.open "P_NEWS 1,'"&session("area")&"',0",conn,1,1 --所有记录