Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SETs and Function

Status
Not open for further replies.

Morpheus1981

Programmer
Aug 9, 2001
105
CR
This is what I am trying to do, I wanted to get a month name in diferent laguages so Created a function and resets the language, but it seems I cannot use any SET instruction into fuctions in SQL Server does anyone know a way to do this without doing it manually... I mean out my Function

CREATE FUNCTION spGenNombreMes
(@tnumMes Numeric(2,0),
@tindIngles numeric(1,0) = 0) RETURNS VARCHAR(30)
AS
BEGIN
DECLARE
@lnNumMes numeric(2,0),
@lcNombreMes VARCHAR(15),
@lcOldIdiom VARCHAR(12)

select @lcOldIdiom = @@LANGUAGE
IF @tindIngles = 0
SET LANGUAGE 'SPANISH'
ELSE
SET LANGUAGE 'US_ENGLISH'

select @lcNombreMes = datename(month,DATEADD(month, @tnumMes , '12/01/2002'))
SET LANGUAGE @lcOldIdiom
return @lcNombreMes;
END
 
Why don't you try writing that line in a stored procedure and calling it from the function?

Good luck.
 
Only "extended stored procedures" can be from within a function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top