Delete a record in a stored procedure

This is for a school project.  I'm new at this and I'm short on time.  If someone can help, I would appreciate it!
I am working in Visual Studio 2010, connected to a SQL Server database.  I have a stored procedure that keeps giving me errors

This is the procedure:
ALTER PROCEDURE spDeleteExpenses
      (
      @owner_id int,
      @date date,
      @expense_type varchar(20)
      )
AS
EXEC      ('
      DELETE FROM Expenses
      WHERE owner_id = ('+ @owner_id +')
      AND   date = ('+ @date +')
      AND   expense_type = ('+ @expense_type +')
      ');
      RETURN

This is what I see in the output window:
Running [spDeleteExpenses] ( @owner_id = 1, @date = 4/18/2011, @expense_type = Fuel ).

Operand type clash: date is incompatible with int
Invalid column name 'Fuel'.
No rows affected.
(0 row(s) returned)
@RETURN_VALUE = 0
Finished running [spDeleteExpenses].

If I take out the date and expense_type parameters, it runs fine.  The columns in the database are of the same type as I have declared in the stored procedure.

IBC-MESAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul JacksonSoftware EngineerCommented:
Can't see why you need to use exec try :

ALTER PROCEDURE spDeleteExpenses
      (
      @owner_id int,
      @date date,
      @expense_type varchar(20)
      )
AS
      DELETE FROM Expenses
      WHERE owner_id = @owner_id
      AND   date = @date
      AND   expense_type = @expense_type

      RETURN

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IBC-MESAuthor Commented:
That got rid of the errors, but didn't actually delete the row from the table.
0
IBC-MESAuthor Commented:
After the changes, the current output is:
Running [spDeleteExpenses] ( @owner_id = 1, @date = 4/18/2011, @expense_type = Fuel ).

No rows affected.
(0 row(s) returned)
@RETURN_VALUE = 0
Finished running [jhill].[spDeleteExpenses].
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Paul JacksonSoftware EngineerCommented:
That suggests no matching record found, is the date stored in the same format in the database and is the datatype of the Date column Date.

Probably worth putting some square brackets round Date as it will be a reserved word:

ALTER PROCEDURE spDeleteExpenses
      (
      @owner_id int,
      @date date,
      @expense_type varchar(20)
      )
AS
      DELETE FROM Expenses
      WHERE owner_id = @owner_id
      AND   [date] = @date
      AND   expense_type = @expense_type

      RETURN

0
IBC-MESAuthor Commented:
I found an something that I missed.  After following your instructions, it worked properly and deleted the row!  Thank you very much!
0
IBC-MESAuthor Commented:
Thanks for the help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.