在SQL 2k8下写的,在SQL 2K下报错
在SQL 2k8下写的,在SQL 2K下报错
declare @tpbom table (root1 nvarchar(20), father nvarchar(20), itemcode nvarchar(20), nlevel int, endflag varchar(2) )
declare @level int
select @level = 0
insert into @tpbom select code as root1, code as father, code as itemcode, 0 as nlevel, 'N' as endflag
from oitt
where treetype = 'p' and code between 'FCS092366A' and 'FCS092366A'
while @level < 8
begin
set @level = @level +1
insert into @tpbom select tt.root1, tt.itemcode father, it.code itemcode, nlevel = @level, 'Y' endflag
from @tpbom tt inner join itt1 it on tt.itemcode = it.father and tt.nlevel = @level -1
inner join oitt oi on it.father = oi.code and oi.treetype = 'P'
if(@@rowcount <= 0 or @level > 8)
break
end
update @tpbom set endflag = 'N' where endflag = 'Y' and itemcode in (select code from oitt where treetype = 'p')
SELECT t0.root1[BOM_PD],t1.itemcode[BOM_father],t1.ItemName,
t2.itemcode[BOM_child],t2.ItemName,t3.price,t3.currency,t0.nlevel [level]
from @tpbom t0 left join OITM t1 ON t0.father = t1.itemcode
left join OITM t2 ON t2.itemcode = t0.itemcode
inner join itm1 t3 ON t3.itemcode = t2.itemcode and t3.pricelist = 2
where t0.nlevel<>0
error: 消息 446,级别 16,状态 9,第 13 行
Cannot resolve collation conflict for equal to operation.
请高手帮忙,是哪里的问题呢?