SELECT tID , [Country] , [Day] , [Month]
FROM ( SELECT t2.tID , t1.ColName , t2.Txt FROM Table1 AS t1 JOIN Table2
AS t2 ON t1.ColId = t2.ColID )
p PIVOT ( MAX([Txt]) FOR ColName IN ( [Country], [Day], [Month] ) ) AS pvt ORDER BY tID ;
sql for everyone
SELECT tID , [Country] , [Day] , [Month]
FROM ( SELECT t2.tID , t1.ColName , t2.Txt FROM Table1 AS t1 JOIN Table2
AS t2 ON t1.ColId = t2.ColID )
p PIVOT ( MAX([Txt]) FOR ColName IN ( [Country], [Day], [Month] ) ) AS pvt ORDER BY tID ;