Dynamic Query

  • Hi All,

    I have to generate a dynamic query for the below mentioned keywords to update them in Title_Update column

    Keywords

    Recruitment

    Employee Engagement

    Performance Management

    Training and Development

    Compensation and Benefits

    Human Resource

    Diversity and Inclusion

    Also it should have the below mentioned Job Level

    Chief Level

    Director Level

    Head Level

    Manager Level

    Managing Director

    Vice President Level

     

    Need them to update in Title_Update column like

    Chief Human Resource Officer

    Vice President of Human Resource

    Director of Training and Development   etc

     

     

     

     

  • UPDATE t
    SET t.Title_Update = CONCAT(T1.Descr, T2.Descr)
    FROM YourTable t
    CROSS APPLY(VALUES (CASE
    WHEN Job_Level = 'Chief Level' THEN 'Chief '
    WHEN Job_Level = 'Director Level' THEN 'Director of '
    WHEN Job_Level = 'Head Level' THEN 'Head of '
    WHEN Job_Level = 'Manager Level' THEN 'Manager of '
    WHEN Job_Level = 'Managing Director' THEN 'Managing Director of '
    WHEN Job_Level = 'Vice President Level' THEN 'Vice President of '
    ELSE ''
    END)) T1(Descr)
    CROSS APPLY(VALUES (CASE
    WHEN Title LIKE '%Human Resource%' THEN 'Human Resource'
    WHEN Title LIKE '%Recruitment%' THEN 'Recruitment'
    WHEN Title LIKE '%Employee Engagement%' THEN 'Employee Engagement'
    WHEN Title LIKE '%Performance Management%' THEN 'Performance Management'
    WHEN Title LIKE '%Training and Development%' THEN 'Training and Development'
    WHEN Title LIKE '%Compensation and Benefits%' THEN 'Compensation and Benefits'
    WHEN Title LIKE '%Diversity and Inclusion%' THEN 'Diversity and Inclusion'
    ELSE 'Human Resource'
    END)) T2(Descr)
    ;
  • There is no information you have provided that we can use to help you.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • This was removed by the editor as SPAM

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply