Please bear with me as I'm still new to programming.
I have an openquery to a linked AS400 which is working fine using a where clause of where pslot >= @pslot, but I would like to capture where pslot is >=@pslot_begin and <=@pslot_end, can anyone help me with the correct syntax to do this ??
As you can see I've had a go myself but I either get an error message about tokens or currently about incorrect syntax near the keyword AND, an extract of my openquery as it stands at the moment is as follows;
set @result = 'SELECT *, dbo.CalcQty(fuomm,qshst,uomcv,uombt)Sales_Quantity INTO tbl_sales_history_enquiry
FROM OPENQUERY(BUSINT, "SELECT ECSTNE Cust_Num, EDTNOE DAC_No, ESREP2 Sales_Rep,
PSLOT Time_Slot, XSHST Sales_Value, XSBUY Purchase_Value, GICAT1 Item_Catrgory, GIGRP1
Item_Group, DITMD Item_Desc,UOMBU1 Base_UOM, UOMTU Trans_UOM,
GICLS Commodity, GBRND1 Brand, DCNAM Cust_Name, DICAT Item_Cat,
DIGRP Item_Grp, DBRND Brand_Name, DSREP Sales_Rep2, GAREA2 Area_Code, GTGRP2
Trading_Grp, GTCAT2 Trading_Cat, DAREA Area_Desc, DTGRP Trading_Grp2, DTCAT Trading_Cat2,
(eitn14 || eitn24 || eitn34 || eitn44 || eitn54)item_code,fuomm,qshst,uomcv,uombt FROM SALESPER where PSLOT >='+ convert(varchar, @pslot_begin)+ ''AND 'PSLOT <='''+ convert(varchar,@pslot_end)+'")'