0
Ich erhalte diesen Fehler beim Verbinden einer Tabelle mit Cross Apply aus einer Tabelle, die von einer Funktion zurückgegeben wurde. Ich habe viele Online-Lösungen ausprobiert, aber kein einziger funktionierte für mich.Der mehrteilige Bezeichner konnte nicht an Kreuz gebunden werden.
Select LTRIM(RTRIM(i.block_num)) as block_num,LTRIM(RTRIM(i.type_code)) as type_code,LTRIM(RTRIM(i.wire_side)) as wire_side,LTRIM(RTRIM(i.grade_spec_made)) as Grade_spec,LTRIM(RTRIM(i.Order_Id)) as Order_Id,LTRIM(RTRIM(i.item_num)) as item_num,CAST(LTRIM(RTRIM(i.width_ord)) AS Decimal(15,2)) as width_ord,LTRIM(RTRIM(i.len_sheet_ord)) as len_sheet_ord,
CAST(LTRIM(RTRIM(i.diam_min)) AS Decimal(15,2)) as diam_min,CAST(LTRIM(RTRIM(i.diam_ord)) AS Decimal(15,2)) as diam_ord,CAST(LTRIM(RTRIM(i.diam_max)) AS Decimal(15,2)) as diam_max,LTRIM(RTRIM(i.core_id)) as core_id,
CAST(LTRIM(RTRIM(i.diam_core)) AS Decimal(15,2)) as diam_core,LTRIM(RTRIM(i.wire_side)) as wire_side,LTRIM(RTRIM(i.rolls_per_pack)) as rolls_per_pack,LTRIM(RTRIM(i.roll_non_edge)) as roll_non_edge,
LTRIM(RTRIM(i.make_to_len_flag)) as make_to_len_flag,LTRIM(RTRIM(i.roll_wgt_flag)) as roll_wgt_flag,LTRIM(RTRIM(i.rolls_ord)) as rolls_ord,LTRIM(RTRIM(i.length_ord)) as length_ord,
CAST(LTRIM(RTRIM(i.wgt_ord)) AS Decimal(15,2)) as wgt_ord,LTRIM(RTRIM(i.ts_ship_prom)) as ts_ship_prom,LTRIM(RTRIM(i.length_min)) as length_min,LTRIM(RTRIM(i.length_max)) as length_max,
LTRIM(RTRIM(i.perc_over)) as perc_over,LTRIM(RTRIM(i.perc_under)) as perc_under,CAST(LTRIM(RTRIM(i.length_nominal)) AS Decimal(15,2)) as length_nominal,LTRIM(RTRIM(i.type_code_trades)) as type_code_trades,
LTRIM(RTRIM(i.width_conv)) as width_conv, LTRIM(RTRIM(i.Mill_id)) as mill_id, LTRIM(RTRIM(i.machine_type)) as machine_type, LTRIM(RTRIM(CAST(ROUND (i.wgt_sched , 2 , 1) as decimal(18,2)))) as wgt_sched,LTRIM(RTRIM(i.machine_id)) as Machine_id, dateadd(s,ts_ship_plan,'19700101 05:00:00:000') as ShipDate,
LTRIM(RTRIM(i.article_id)) as article_id, LTRIM(RTRIM(i.grain_direction)) as grain_direction ,
(SELECT TOP 1 LTRIM(RTRIM(intertrim_num)) FROM grade_spec WHERE grade_spec.grade_spec = i.grade_spec) AS intertrim_num,
(SELECT TOP 1 cons_name FROM consignee WHERE consignee.consignee_id = i.consignee_id) AS cons_name_full,
(SELECT TOP 1 CASE WHEN Len(LTRIM(RTRIM(cons_name))) > 10 THEN SUBSTRING (LTRIM(RTRIM(cons_name)) ,0 , 10) + '..' ELSE LTRIM(RTRIM(cons_name)) END FROM consignee WHERE consignee.consignee_id = i.consignee_id) AS cons_name
,s.wgt_trim_plan,
(i.wgt_ord-s.wgt_trim_plan) as wgt_untrim
,w.wgt_select,w.max_wgt,w.min_wgt,w.misc_loss
from order_blocks b, order_item i, order_status s, mach_sched m
left join unit_status u on u.stat=m.stat and table_name = 'mach_sched'
CROSS APPLY
GetOrderWeightsTest('MX1','WD','02','MX1','PM','01',i.block_num,i.Order_Id,i.item_num,i.grade_spec_made ,i.perc_over,i.perc_under,i.type_code_trades,i.type_code) w
where b.order_id = i.order_id and b.item_num = i.item_num and b.machine_type=i.machine_type and i.order_id = s.order_id and i.item_num = s.item_num and i.wgt_ord>s.wgt_trim_plan and b.mill_id=m.mill_id and b.machine_type=m.machine_type and b.machine_id=m.machine_id and b.block_num=m.block_num and i.type_code='R'
Fehlerprotokoll:
Msg 4104, Level 16, State 1, Line 18
The multi-part identifier "i.block_num" could not be bound.
Msg 4104, Level 16, State 1, Line 18
The multi-part identifier "i.Order_Id" could not be bound.
Msg 4104, Level 16, State 1, Line 18
The multi-part identifier "i.item_num" could not be bound.
Msg 4104, Level 16, State 1, Line 18
The multi-part identifier "i.grade_spec_made" could not be bound.
Msg 4104, Level 16, State 1, Line 18
The multi-part identifier "i.perc_over" could not be bound.
Msg 4104, Level 16, State 1, Line 18
The multi-part identifier "i.perc_under" could not be bound.
Msg 4104, Level 16, State 1, Line 18
The multi-part identifier "i.type_code_trades" could not be bound.
Msg 4104, Level 16, State 1, Line 18
The multi-part identifier "i.type_code" could not be bound.
Es funktioniert gut, ohne 'CROSS GetOrderWeightsTest (‚MX1‘GILT,‚WD‘,‚02‘,‚MX1‘,‚PM‘ , '01', i.block_num, i.Order_Id, i.item_num, i.grade_spec_made, i.perc_over, i.perc_under, i.type_code_trades, i.type_code) w' –
@farhanali - ja ohne Kreuz anwenden wird es funktionieren aber die Spalten können nicht in "Cross Apply" -Reihenfolge referenziert werden, könnte das Problem sein –