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

Delete record SP not working... 1

Status
Not open for further replies.

Amesville

Programmer
Oct 10, 2011
93
US
Hi Folks

I have a very simple SP to delete a record with a passed-in (key) value. I have essentially the same procedure in place on another table and it works fine, this one does not work (the record does not get deleted). I have made certain that the correct key value is being sent in the procedure call.

Code:
ALTER PROCEDURE [dbo].[spMCommDelRec] 
    @Par1  Varchar(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
    -- Insert statements for procedure here
    DELETE FROM Commodity WHERE CommodityName = '@Par1'; 
END

I have been trying to figure this out all weekend, I don't understand what I could be doing wrong.

Any ideas?

Craig

 
remove the single-quotes.

With the single-quotes in there, you end up with a hard coded string instead of using the parameter.

Code:
ALTER PROCEDURE [dbo].[spMCommDelRec] 
    @Par1  Varchar(50)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    DELETE FROM Commodity WHERE CommodityName = @Par1; 
END


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
OMG Thank you George! That did it. I feel Sooooooo dumb...

Moving on to greater things now. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top