I have a filler field that stores to sets of data. Filler_001 field is char(42).First 5 characters are for Cust_typeNext 15 are for item_no. I'm doing an insert from another table. So the cust_type could be any number of characters 1 thru 5. When I grab the cust type value and if its under 5 characters I need to add trailing spaces. Field should look like this:1 ITEM112 ITEM2123 ITEM31234 ITEM412345ITEM5Here is my try:INSERT INTO oeprcfil_sql ( cd_tp, curr_cd, filler_0001, start_dt, end_dt, cd_prc_basis, minimum_qty_1, prc_or_disc_1, minimum_qty_2, prc_or_disc_2, minimum_qty_3, prc_or_disc_3, minimum_qty_4, prc_or_disc_4, minimum_qty_5, prc_or_disc_5, minimum_qty_6, prc_or_disc_6, minimum_qty_7, prc_or_disc_7, minimum_qty_8, prc_or_disc_8, minimum_qty_9, prc_or_disc_9, minimum_qty_10, prc_or_disc_10, filler_0004 ) SELECT ex.cd_tp, ' ', left(ex.cd_tp_3_cust_type&space(5),5)+ex.cd_tp_3_item_no, ex.start_dt, ex.end_dt, ex.cd_prc_basis, ex.minimum_qty_1, ex.prc_or_disc_1, ex.minimum_qty_2, ex.prc_or_disc_2, ex.minimum_qty_3, ex.prc_or_disc_3, ex.minimum_qty_4, ex.prc_or_disc_4, ex.minimum_qty_5, ex.prc_or_disc_5, ex.minimum_qty_6, ex.prc_or_disc_6, ex.minimum_qty_7, ex.prc_or_disc_7, ex.minimum_qty_8, ex.prc_or_disc_8, ex.minimum_qty_9, ex.prc_or_disc_9, ex.minimum_qty_10, ex.prc_or_disc_10, 'Added on ' + CONVERT(VARCHAR(10), GETDATE(), 110) AS [MM-DD-YYYY] FROM PriceDataBase...PriceCode3Send$ ex LEFT OUTER JOIN oeprcfil_sql c ON c.cd_tp = ex.cd_tp --AND c.curr_cd = ex.curr_cd AND left(c.filler_0001,5) = ex.cd_tp_3_cust_type AND substring(c.filler_0001,6,15) = ex.cd_tp_3_item_no AND c.start_dt = ex.start_dt AND c.end_dt = ex.end_dtWHERE c.cd_tp IS NULL and c.curr_cd is NULL and left(c.filler_0001,5) is NULL and substring(c.filler_0001,6,15) is NULL and c.start_dt is NULL and c.end_dt is NULL
I get the following error when trying to run. The data types nvarchar and varchar are incompatible in the boolean AND operator.