Hi,
I have a source table . Below is the ddl and data.
create table sourcetbl
( player varchar(30), countrycode varchar(3))
insert into sourcetbl values ('sachin','aus')
insert into sourcetbl values ('sachin','sri')
insert into sourcetbl values ('sachin','pak')
insert into sourcetbl values ('sachin','sa')
insert into sourcetbl values ('sachin','afg')
insert into sourcetbl values ('sachin','end')
There is a lookup table as well with DDL and data.
create table lkptbl
( countrycode varchar(3), country varchar(13))
insert into lkptbl values ('aus','australia')
insert into lkptbl values ('sri','srilanka')
insert into lkptbl values ('pak','pakistan')
When I do the lookup between source table Countrycode to Lkptable countrycode and display the Country name.
My requirement is, if any of the source countrycode does not match with lookup table country code, then in the target table , 'country' name should be "Unknown".
I tried 'Ignore failure'. But i am getting NULL for the Non-matching country codes.
Below is the Target table and the desired data wanted. But what I am getting is NULL instead of 'Unknown'.
CREATE TABLE [dbo].[Tgttbl](
[player] [varchar](30) NULL,
[country] [varchar](13) NULL
)
INSERT [dbo].[Tgttbl] ([player], [country]) VALUES (N'sachin', N'australia')
GO
INSERT [dbo].[Tgttbl] ([player], [country]) VALUES (N'sachin', N'srilanka')
GO
INSERT [dbo].[Tgttbl] ([player], [country]) VALUES (N'sachin', N'pakistan')
GO
INSERT [dbo].[Tgttbl] ([player], [country]) VALUES (N'sachin', 'Unknown')
GO
INSERT [dbo].[Tgttbl] ([player], [country]) VALUES (N'sachin', 'Unknown')
GO
INSERT [dbo].[Tgttbl] ([player], [country]) VALUES (N'sachin', 'Unknown')
When I tried the 'Redirect rows to error output' and then used a Derived column transformation - but I am not getting 'Country' as input. What I am getting is Player and Countrycode only. then how can i change NULL to Unknown?
Please help me to get the desired output.
Your help is greatly appreciated.