Need to cech existance of a node within an INSERT/SELECT statement - possible? RRS feed

  • Question

  • Hi Folks -

    I"m sorry, I'm getting greedy today asking a 2nd question so I promise this is my last.

    I have the following query that I am trying to get to work:

    INSERT INTO [ & strTable & ] ( [Cost Center - Long Name]

    ) SELECT Nz(SELECT 'LS01'+[Cost Center - ID] FROM [LT-SAP_CC_CMSO_Mapping],[Cost Center - ID]) FROM [LT-Global_Monthly_Headcount_Shire] LEFT JOIN [LT-SAP_CC_CMSO_Mapping] ON Nz(SELECT 'LS01'+[Cost Center - ID] FROM [LT-SAP_CC_CMSO_Mapping],[LT-Global_Monthly_Headcount_Shire].[Cost Center - ID]) = [LT-SAP_CC_CMSO_Mapping].[Long_Code]

    What I'm trying to do in the SELECT portion is check the existence. And if returns Null, then just use [Cost Center - ID]. Is this possible or is there another way to do this?

    Thank you!

    Tuesday, June 30, 2020 11:46 PM