October 5, 2011 at 11:04 am
I am trying to write the stored procedure below. But I keep getting the error
Incorrect syntax near ';'.
Always at the end of the statement. If I remove the ';' then it gives me
Incorrect syntax near 'END'.
Can anyone tell me how to end this create procedure?
CREATE PROCEDURE em_oeHistory1
@working_date CHAR(8)
AS
BEGIN
BEGIN
If (@working_date <= '')
SET @working_date = CONVERT(VARCHAR(8), GETDATE(), 112 )
End
Delete From EMOEHSTSTATUS Where POSTED_INV_DATE = GetDate();
Insert Into EMOEHSTSTATUS (POSTED_INV_DATE, Invoice_Date, START_TIME) Values (GetDate(), @working_date, CONVERT(time,GetDate()) ;
END
Thanks for your help!
October 5, 2011 at 11:07 am
CREATE PROCEDURE em_oeHistory1 @working_date CHAR(8)
AS
BEGIN
If ( @working_date <= '' )
BEGIN
SET @working_date = CONVERT(VARCHAR(8) , GETDATE() , 112)
End
Delete From
EMOEHSTSTATUS
Where
POSTED_INV_DATE = GetDate() ;
Insert Into
EMOEHSTSTATUS
(
POSTED_INV_DATE
, Invoice_Date
, START_TIME
)
Values
(
GetDate()
, @working_date
, CONVERT(time , GetDate())
) ;
END
October 5, 2011 at 11:14 am
Thank you Ninja's_RGR'us!
That worked!!
October 5, 2011 at 11:19 am
As Remi did, a little indentation (formatting) goes a long way to helping resolve little problems like what you were experiencing.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
October 5, 2011 at 11:22 am
steve 11373 (10/5/2011)
Thank you Ninja's_RGR'us!That worked!!
HTH.
You ahd 2 begins one after another. The 2nd one needed to be after the if.
Then you were missing and parenthesis after the last getdate().
the thing is that those 2 characters are like terminators. So if they're out of place the engine has a hard time spotting to exact line error.
the easy way out is to comment all the code and add a little bit at a time untill you find <all> the error(s).
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply