March 31, 2014 at 1:34 pm
Hello guys, I am sorry if this question is trivial
Is there a way to make a single insert (in a loop) and take system dates and insert them in different languages without making a new loop for each language.
Example
Create table dateLanguage(
monthName nvarchar(20),
monthNameEs nvarchar(20),
monthNameFr nvarchar(20),
MonthNamePt nvarchar(20)
)
So for example
January,
Enero,
Janvier,
janeiro
Thanks in advance for the help
March 31, 2014 at 1:54 pm
DECLARE @d AS DATE = '20140101';
INSERT INTO dateLanguage([monthName],monthNameEs,monthNameFr,MonthNamePt)
SELECT
FORMAT(@d, N'MMMM', N'en-us'),
FORMAT(@d, N'MMMM', N'es-es'),
FORMAT(@d, N'MMMM', N'fr-fr'),
FORMAT(@d, N'MMMM', N'pt-pt');
GO
SELECT * FROM dateLanguage;
[font="Courier New"]monthName monthNameEs monthNameFr MonthNamePt
-------------------- -------------------- -------------------- --------------------
January enero janvier Janeiro
[/font]
___________________________
Do Not Optimize for Exceptions!
March 31, 2014 at 1:54 pm
You could use the syslanguages view along with the DelimitedSplit8K[/url] and Crosstabs[/url].
SELECT
MAX( CASE WHEN name = 'us_english' THEN s.Item END ) English
,MAX( CASE WHEN name = 'Deutsch' THEN s.Item END ) Deutsch
,MAX( CASE WHEN name = 'Français' THEN s.Item END ) French
,MAX( CASE WHEN name = 'Español' THEN s.Item END ) Spanish
,MAX( CASE WHEN name = 'Italiano' THEN s.Item END ) Italian
FROM sys.syslanguages l
CROSS APPLY dbo.DelimitedSplit8K( months, ',') s
GROUP BY s.ItemNumber
March 31, 2014 at 2:54 pm
Thanks both of you for your help, I appreciate it.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply