How to solve this ..?

  • Help me out how to solve this requirement

    Table_1

    Col1Col2Col3Col4

    1101Usr1WRK1

    2101Usr2WRK1

    Table_2

    Col1Msg

    101User %1 Logged on %2

    Expected Output

    User Usr1 logged on WRK1

    User Usr2 logged on WRK1

  • What have you tried?

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • Could you post your issue properly???

  • DECLARE @Table_1 TABLE (Col1 int, Col2 int, Col3 char(4), Col4 char(4))

    INSERT INTO @Table_1 SELECT 1, 101, 'Usr1', 'WRK1'

    UNION ALL SELECT 2, '101', 'Usr2', 'WRK1'

    DECLARE @Table_2 TABLE (Col1 int, Msg char(20))

    INSERT INTO @Table_2 SELECT 101, 'User %1 Logged on %2'

    SELECT REPLACE(REPLACE(B.Msg, '%1', A.Col3), '%2', A.Col4)

    FROM @Table_1 A INNER JOIN @Table_2 B ON B.Col1 = A.Col2

    ORDER BY A.Col1

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

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