Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Unanswered: Must declare the scalar variable "@MyDate".

    I have write a store procedure to delete all rows that belong to particular date. But I am keep receiving error message Must declare the scalar variable "@MyDate". I am new to SQL Server please help to complete my project

    Code:
    CREATE PROCEDURE deleteBankData
    	@MyMonth  datetime
    AS
    DELETE FROM BankData
    WHERE ReconcileDate = @MyDate

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Should @MyDate be @MyMonth?
    George
    Home | Blog

  3. #3
    Join Date
    Dec 2008
    Posts
    135
    ALTER PROC deleteBankData
    @MyMonth datetime
    AS
    DELETE FROM BankData
    WHERE dateadd(dd,datediff(dd,0,ReconcileDate),0)
    = @MyMonth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •