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!

Incorrect syntax near the keyword 'SET'. Help me!

Status
Not open for further replies.

marcela24

Programmer
Feb 17, 2003
72
NL
I'm trying to create a function in SQL Server 2000 and i'm having the error message: Incorrect syntax near the keyword 'SET'.
I've tried but i can't fix this. does anybody can help me?

Here is the code:
CREATE FUNCTION fMelhor_precisao_hora
( @veiculo nvarchar(50),
@data_inicio datetime,
@data_fim datetime )

RETURNS @Pontos_no_intervalo TABLE
( latitude nvarchar(50),
longitude nvarchar(50),
data datetime,
hora int )
AS
BEGIN
WHILE ( @data_inicio <= @data_fim )
BEGIN
INSERT @Pontos_no_intervalo
SELECT latitude, longitude, dtponto, DATEPART ( hh, @data_inicio ) as hora
FROM tpontos
WHERE id_veiculo = @veiculo AND dtponto = @data_inicio
GROUP BY hora
HAVING MIN ( precisao )
SET @data_inicio = DATEADD ( dd, 1, @data_inicio )
END
RETURN
END
GO
 
You have to specify a a condition for the having clause

HAVING MIN ( precisao ) = 4711

or whatever is apropriate in your case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top