CREATE PROCEDURE Book_PageGetBooks1
(
@ClassIDs varchar(500)
)
as
set nocount on
begin
declare @indextable table(id int identity(1,1),nid int) --查询
select O.BookID
from Book_Books O,
@indextable t
where O.BookID=t.nid
and charindex(','+convert(varchar,BookID)+',',','+@ClassIDS +',')>0
order by t.id
end
set nocount off
GO
(
@ClassIDs varchar(500)
)
as
set nocount on
begin
declare @indextable table(id int identity(1,1),nid int) --查询
select O.BookID
from Book_Books O,
@indextable t
where O.BookID=t.nid
and charindex(','+convert(varchar,BookID)+',',','+@ClassIDS +',')>0
order by t.id
end
set nocount off
GO
(
@ClassIDs varchar(500)
)
as
set nocount on
begin
create table #(id int identity(1,1),nid int)
insert into # select Bookid from Book_Books --查询
exec(' select O.BookID'+
' from Book_Books O,'+
' # t '+
' where O.BookID=t.nid'+
' and BookID in ('+@ClassIDS +')'+
' order by t.id'
) drop table #
end
set nocount off
GO
你的charindex(','+convert(varchar,BookID)+',',','+@ClassIDS +',')>0
得不到任何结果
上面的那个函数可以代替BookID in ('+@ClassIDs+')吗
我是这样执行存储过程的,应该算是用分隔符了吧
我刚刚也查询了一下charindex的用法,感觉我会被一些逗号搞晕掉
sql里面的符号感觉特别麻烦
vivianfdlpw()的第一个方法的@indextable t表为空!当然没有结果!
insert into @indextable(nid) select Bookid from Book_Books
丢失了