I have a database structure, for example:
SELECT * FROM Culture;
I want the SQL query to give me the following results:
Key CategoryName en-US fr-FR another-SupportedCulture And so on ------------------------------------------------------------------------------------------------------------------------------------------------------------- Hello JavaScript Hello Bonjour Value of hello in that supported culture and so on for all supported cultures HowAreYou JavaScript How are you? Comment allez-vous? Value of HowAreYou in that supported culture and so on for all supported cultures
I know how to write a query for a particular culture. I believe that I will write individual queries for all cultures in the Culture
table, whose Supported
field is set to 1 ( true
). Then I applied the LEFT OUTER JOIN between the English culture (which will have all the meanings) and all other cultures to get the above dataset.
So far, I have written so far for a separate culture:
SELECT ResourceKey.Id AS ResourceKeyId, ResourceKey.Name AS [Key], Category.Name AS CategoryName, Culture.Id AS CultureId, Culture.ShortName AS CultureShortName, Strings.ResourceValue FROM ResourceKey LEFT OUTER JOIN Strings ON ResourceKey.Id = Strings.ResourceKeyId INNER JOIN Culture ON Strings.CultureId = Culture.Id LEFT OUTER JOIN StringCategory ON ResourceKey.Id = StringCategory.ResourceKeyId LEFT OUTER JOIN Category ON StringCategory.CategoryId = Category.Id WHERE Strings.CultureId = 23;
Which returns the following results:
ResourceKeyId Key CategoryName CultureId CultureShortName ResourceValue ---------------------------------------------------------------------------------- 20571 Hello JavaScript 23 fr-FR Bonjour 20572 HowAreYou JavaScript 23 fr-FR Comment allez-vous?
Thing is: I'm not sure how to start writing a loop in T-SQL and then store these separate datasets in a temporary memory area (I believe there is a term for it, for some table type expressions that are in memory and only for of the entire T-SQL period, specifically for situations like mine) in the SQL process, and then applying the join to them. This is where I need help.
Thank you for your patience in reading my question and help.
I am using Microsoft SQL Server 2008 Express R2.