Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Why this procedure does not work ?

Author  Topic 

paradise_wolf
Starting Member

32 Posts

Posted - 2007-03-01 : 13:43:11
I intended to make updates in two different tables with just one procedure:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALTER PROCEDURE UpdateNonEbookOrders2
(@OrderID INT,
@ProductID INT,
@UserName VARCHAR(50),
@FirstName VARCHAR(50),
@LastName VARCHAR(150),
@CustomerEmail VARCHAR(50),
@NumOfItems INT,
@ShippingAddress VARCHAR(500),
@ShippingCity VARCHAR(50),
@ShippingCounty VARCHAR(50),
@ShippingZip VARCHAR(20),
@ShippingCountry VARCHAR(50),
@ShippingTelephone VARCHAR(50),
@DateCreated SMALLDATETIME,
@PaymentConfirmed BIT,
@Completed BIT,
@Canceled BIT,
@Comments VARCHAR(500),
@ProductName VARCHAR(100),
@IsEbook BIT,
@Quantity INT,
@Prepared BIT,
@DateSent SMALLDATETIME,
@Received BIT,
@UnitCost MONEY)
AS
UPDATE OrderDetail
SET ProductName = @ProductName, IsEbook = @IsEbook, Quantity = @Quantity,Prepared = @Prepared,DateSent = @DateSent, Received = @Received, UnitCost = @UnitCost
WHERE OrderID = @OrderID AND ProductID = @ProductID

UPDATE Orders
SET UserName = @UserName, FirstName = @FirstName, LastName = @LastName, CustomerEmail = @CustomerEmail,
NumOfItems = @NumOfItems, ShippingAddress = @ShippingAddress, ShippingCity = @ShippingCity,
ShippingCounty = @ShippingCounty, ShippingZip = @ShippingZip, ShippingCountry = @ShippingCountry,
ShippingTelephone = @ShippingTelephone, DateCreated = @DateCreated, PaymentConfirmed = @PaymentConfirmed,
Completed = @Completed, Canceled = @Canceled, Comments = @Comments
WHERE OrderID = @OrderID

X002548
Not Just a Number

15586 Posts

Posted - 2007-03-01 : 13:57:59
Well, it might if you let us know what's not working or what errors you are getting.

Plus if you give us DDL and sample data in the form of DML, that might help



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

paradise_wolf
Starting Member

32 Posts

Posted - 2007-03-01 : 17:03:52
Hi X002548

I just found out that the procedure is fine. The error actually was in a method that was passing the value of a wrong variable.

Thank you, anyway.
Go to Top of Page
   

- Advertisement -