views:

61

answers:

2

Question: The new SQL Server 2008 database returns me values formatted English (date/float).

Is there a way I can set the return format ?

For example temporarely switching the database language?

Or just set the language for the current query ?

A: 

You cannot switch the language in SQL Server for just a single statement or specify a different language for a select.

What you need to do is:

  • either convert DATETIME to string using an appropriate "style" value in your CONVERT statement (see the MSDN docs on CONVERT for details)
  • have a batch to switch to the language needed, execute your statement, and then switch back
  • don't do the switching on the SQL Server side, but in your application
marc_s
+1  A: 

BOL: Specifies the language environment for the session. The session language determines the datetime formats and system messages.

DECLARE @Today DATETIME
    SET @Today = '12/5/2007'

    SET LANGUAGE Italian
    SELECT DATENAME(month, @Today) AS 'Month Name'

    SET LANGUAGE us_english
    SELECT DATENAME(month, @Today) AS 'Month Name' 
    GO
igor