Error while creating a function, please kindly advice

Posted on 2005-05-04
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

    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
    Hi LegalIT!

    Have you check your other question ???

    We need some feedback from you.

    eNTRANCE2002 :-)
    LVL 68

    Expert Comment

    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

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    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 the fundamental information of how to create a table.

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now