Created
January 12, 2018 22:57
-
-
Save sotirisf/29cb9ccbb8289d7a38d4da989fc2f490 to your computer and use it in GitHub Desktop.
Get Umbraco dictionary entries for all languages in a pivoted table (each language with its own column)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @DynamicColumns NVARCHAR(MAX); | |
DECLARE @DynamicSQL NVARCHAR(MAX); | |
SELECT @DynamicColumns = COALESCE(@DynamicColumns+', ', '')+QUOTENAME(languageISOCode) | |
FROM | |
( | |
SELECT DISTINCT | |
languageISOCode | |
FROM umbracolanguage | |
) AS FieldList; | |
SET @DynamicSQL = | |
'SELECT [key], ' + @DynamicColumns | |
+ ' FROM' | |
+ ' (' | |
+ 'SELECT l.languageISOCode, d.[key], t.[value]' | |
+ ' FROM cmsDictionary d' | |
+ ' INNER JOIN cmsLanguageText t ON d.id = t.UniqueId' | |
+ ' INNER JOIN umbracoLanguage l ON l.id = t.languageId' | |
+ ') AS sourceTbl PIVOT(MAX([value]) FOR languageisocode IN(' + @DynamicColumns + ')) AS pvt' | |
+ ' ORDER BY [key];' | |
execute (@DynamicSQL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment