Monday, March 19, 2012

Help needed with Simple Stored Procedure

Hey all,

Can anyone tell me why this stored procedure doesn't work?

ALTER

PROCEDURE [dbo].[RemoveLocation]

@.Id

int,

@.Name

varchar

AS

DELETE

FROM Classifieds_Terminals

WHERE

[Id]= @.Idand [Name]= @.Name

I try exeuting it like this:

USE

[CLASSIFIEDSDB2.MDF]

GO

DECLARE

@.return_valueint

EXEC

@.return_value= [dbo].[RemoveLocation]

@.Id

= 18,

@.Name

= N'Terminal A'

SELECT

'Return Value'= @.return_value

GO

It returns 0 and nothing happens...?

Here is the table:

id | Name

18 Terminal A
18 Terminal B
18 Terminal C

Hi,

i have modified your Stored Procedure, now it should working as expected:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

ALTER PROCEDURE [dbo].[RemoveLocation] @.Id int,@.Name varchar(100)
AS

DELETE FROM Classifieds_Terminals WHERE [Id] = @.Id and [Name] = @.Name

RETURN (SELECT @.@.ROWCOUNT)

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Regards
Marc André

|||

Thanks,

I also added a autoincrement field and used that id to delete the entry.

No comments:

Post a Comment