HashHazard
HashHazard

Reputation: 561

SQL Server stored procedure with parameters

I'm brand new to SQL Server and trying to write a stored procedure that updates a recordset with the current date/time at the time the stored procedure is called. My code keeps reporting an error near the =. The parameter @SentFax is the PK of the record needing to be updated, any ideas why this doesn't work?

CREATE PROCEDURE FaxMailerSent 
-- Add the parameters for the stored procedure here
@SentFax int = 0, 
  = 
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
UPDATE FaxMailer 
    SET Done = GetDate()
        WHERE [Fax_ID] = @SentFax; 
END
GO

Upvotes: 0

Views: 174

Answers (2)

Santosh
Santosh

Reputation: 12353

Try below

CREATE PROCEDURE FaxMailerSent 
-- Add the parameters for the stored procedure here
@SentFax int = 0
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
UPDATE FaxMailer 
    SET Done = GetDate()
        WHERE [Fax_ID] = @SentFax; 
END
GO

Upvotes: 0

Dennis Traub
Dennis Traub

Reputation: 51624

Remove the ,after @SentFax int = 0 and the = between @SentFax int = 0 and AS.

The following should work as expected:

CREATE PROCEDURE FaxMailerSent 
    @SentFax int = 0
AS
BEGIN
SET NOCOUNT ON;

UPDATE FaxMailer 
    SET Done = GetDate()
        WHERE [Fax_ID] = @SentFax; 
END
GO

Upvotes: 1

Related Questions