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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why do I get error 170 "Incorrect syntax near @v_year" in this proc?

Status
Not open for further replies.

rjsql

MIS
Joined
Apr 2, 2003
Messages
5
Location
US
SET @v_Start_Year = CONVERT(INT,SUBSTRING(CONVERT (CHAR,@p_TZ_Start_Date),1,4))
SET @v_End_Year = CONVERT(INT,SUBSTRING(CONVERT(CHAR,@p_TZ_End_Date),1,4))

SET @v_year = @v_Start_Year


/* Create array of specific start and end dates after taking into account */
/* Daylight Savings Time */
WHILE ( @v_year <= @v_End_Year )
BEGIN --> ***right here***

EXEC Convert_DST(@v_year, @v_DST_Start, @v_Local_DST_Start_Date, @v_Local_DST_Start_Time, @po_Error_Code OUTPUT, @po_Error_Msg OUTPUT)
IF @po_Error_Code > 0
BEGIN
SET @E_ERROR_CODE = @po_Error_Code
SET @E_ERROR_MSG = @po_Error_Msg
GOTO EXCEPTION
END

EXEC Convert_DST(@v_year, @v_DST_End, @v_Local_DST_End_Date, @v_Local_DST_End_Time, @po_Error_Code OUTPUT, @po_Error_Msg OUTPUT)
IF @po_Error_Code > 0
BEGIN
SET @E_ERROR_CODE = @po_Error_Code
SET @E_ERROR_MSG = @po_Error_Msg
GOTO EXCEPTION
END

IF( (@v_TZ_Start_Date <= @v_Local_DST_Start_Date) and (@v_Local_DST_Start_Date <= @v_TZ_End_Date))
BEGIN
--v_DST_Local_Date_array.EXTEND;
--v_DST_Local_Date_array(v_cnt) := @v_Local_DST_Start_Date;
@v_cnt := @v_cnt + 1
END

IF( @v_TZ_Start_Date <= @v_Local_DST_End_Date and @v_Local_DST_End_Date <= @v_TZ_End_Date)
BEGIN
--v_DST_Local_Date_array.EXTEND;
--v_DST_Local_Date_array(v_cnt) := @v_Local_DST_End_Date;
@v_cnt := @v_cnt + 1
END

@v_year := @v_year + 1

END
 
please provide more info like the declaration of
@p_TZ_Start_Date
@p_TZ_End_Date
@v_Start_Year
@v_End_Year
@v_year
Also what line it is complaining about, you have @v_year in many places in this script. Knowing where about the error occured would help alot

if @p_TZ_Start_Date is a DATETIME
please show what your SQL server displays when you do a
PRINT CONVERT(CHAR,GETDATE())
 
Sorry for the confusion.
Did find out the error -- I did not need parens around the parms for the calls to Convert_DST proc.
Thanks for the reply anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top