Lookup Table 1:
CREATE TABLE [dbo].[LT1](
[LT1_ID] [varchar](25) NULL,
[Desc] [varchar](25) NULL);
insert into [LT1] ([LT1_ID] ,[Desc]) values ("Cat_Code","Category"),
("Prod_Code", "Product")
Lookup Table 2:
CREATE TABLE [dbo].[LT2](
[LT2_ID] [varchar](25) NULL,
[Val] [varchar](25) NULL);
insert into [LT2] ([LT2_ID] ,[Val]) values ("Drama__Q__M", "Drama"),
("Comedy__Q__M", "Comedy"),
("Blue__Q_Ray", "BlueRay")
I have another table with the below information
CREATE TABLE [dbo].[History](
[Content] [varchar](25) NULL);
insert into [History] ([Content]) values ("Changed Cat_code to Drama__Q__M From Null"),
("Changed Product_code to Blue__Q__Ray From Null"),
("Assigned to AAA"),
("Changed Cat_code to Comedy__Q__M From Drama__Q__M");
I need to get the lookup values from the lookup tables LT1 and LT2 and replace the respective LT1_ID and LT2_ID value with Desc and Val values from look up tables 1 and 2. the output should look like this
Changed Category to Drama From Null
Changed Product to BlueRay From Null
Assigned to AAA
Changed Category to Comedy From Drama
Can any one please help me in resolving this?
Thank you