感谢您看看这个。插入选择后SQL Server挂起
该问题与以下sql查询有关。基本上,它会递归地查找某个页面(母版页)下的所有页面,然后将母版页的类别(在xref_pages_categories中查找)应用于所有这些页面。
在运行插入时,查询表应该已完全插入的数据挂起。
如果我不跑了插入线查询,结果回来完美,如:
3245 490
3249 490
3252 490
但在把刀片在它的前面和插入,查询的pageid = 3245只是挂起。有任何想法吗?
declare @page int;
set @page=3202;
begin transaction transki;
With FindAllPagesUnderneath(PageID, ParentID) as
(
select id as PageID, ParentPageId as ParentID
from pages where [email protected]
union all
select id as PageID, ParentPageID as ParentID
from pages p
inner join FindAllPagesUnderneath mp on
p.parentpageid=mp.PageID
)
insert into xref_pages_categories (PageID, CategoryID)
--get records that definitely arent already in xref_pages_categories
select * from
(
select distinct thegood.*
from
(
--get all pages under @page attached to new categoryid
select distinct fap2.PageID, fapo.CategoryID
from FindAllPagesUnderneath fap2
cross join (
select fap.PageID,xpc.categoryid
from xref_pages_categories xpc
inner join FindAllPagesUnderneath fap
on fap.PageID=xpc.pageid
where fap.pageid!=1 and
fap.pageid!=1332
and fap.parentid=1332
) fapo
where fap2.pageid [email protected]
) thegood
left outer join xref_pages_categories xpc
on xpc.pageid = thegood.pageid
where xpc.pageid is null
) final
您没有在您的示例中提交事务。该示例中的错误还是错误错误? –
2010-03-03 14:41:14
我相信答案,因为当我没有提交临时表时,它在 – Micah 2010-03-03 19:58:23