[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Error while creating a function, please kindly advice

Posted on 2005-05-04
Medium Priority
Last Modified: 2008-02-01
Dear all experts,

  While I creating a function on my SQL Server, it returns the following error message'

Server: Msg 443, Level 16, State 2, Procedure GetDutchDate2, Line 12
Invalid use of 'SET COMMAND' within a function.

  The function is as follow:

create function dbo.GetDutchDate2 (
      @datTempDate datetime,
      @intFormat int = 1,
      @strSeparator char(1) = '-'
) returns varchar (100)
      --If @intFormat = 1 = Full Month 12-December-2005
      --If @intFormat = 2 = Short Month 12-Dec-2005
      Declare @strTemp varchar (100)

                Set Language 'Dutch'

      If IsDate (@datTempDate) = 1  begin
            if @intFormat = 1 begin
                  Select @strTemp = Convert (varchar, @datTempDate, 106)

            if @intFormat =2 begin
                  Select @strTemp = Replace (Convert (varchar, @datTempDate, 106), ' ', @strSeparator)
      Return @strTemp


It should be something related to line "Set Language 'Dutch'", please kindly provide some help to me.
Question by:LegalIT
LVL 23

Accepted Solution

adathelad earned 375 total points
ID: 13925283
I don't think you can use this command inside a user defined function - some functionality, like this, is restricted within functions. But you'll find it works fine inside a stored procedure
LVL 14

Expert Comment

by:Renante Entera
ID: 13925343
Hi LegalIT!

Have you check your other question ???  http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_21412087.html

We need some feedback from you.

eNTRANCE2002 :-)
LVL 70

Expert Comment

by:Scott Pletcher
ID: 13926617
That could be true about SET LANGUAGE not being allowed in a function.

Also, the only languages in master.dbo.syslanguages that start with 'D' are "Dansk" and "Deutsch" (at least on my SQL Servers).  Review the names in that table and choose the one that best fits what you need.  For example, there is one named "Nederlands".

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question