September 24, 2008 at 12:52 am
Select * from customer
CustomerID CustomerName
----------- --------------
1 TestC1
2 TestC2
3 TestC3
4 TestC4
select * from CustomerTransact
TransID CustomerID TransName Status
--------- ------------- -------- -------
1 1 Trans1 A
2 2 Trans2 A
3 3 Trans3 A
4 4 Trans4 A
Stored procedure to update n number of recordsof customertransact and output that customer record.
Create proc pUpdateCust(@RecToUpdate AS INT)
As
BEGIN
UPDATE TOP(@RecToUpdate) CustomerTransact
SET STATUS = 'D'
OUTPUT Deleted.TransID,
CUSTOMERNAME
FROM CUSTOMER
INNER JOIN CustomerTransact
on CustomerTransact.customerid = customer.customerid
WHERE CustomerTransact.status = 'A'
END
EXEC pUpdateCust 2
OUTPUT the updated customer record 1,2
September 24, 2008 at 1:13 am
Duplicate post.
Replies to the following thread please:
http://www.sqlservercentral.com/Forums/Topic574925-338-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 24, 2008 at 1:18 am
Duplicate of http://www.sqlservercentral.com/Forums/Topic574926-338-1.aspx
Failing to plan is Planning to fail
September 24, 2008 at 2:40 am
xx
September 24, 2008 at 8:47 am
gururajan (9/24/2008)
xx
What does this mean?
Failing to plan is Planning to fail
September 24, 2008 at 8:59 am
They're kisses - but in this context they can be understood as a big-hearted "Thank you kindly".
Or maybe you just got lucky - better grab your coat JIC ๐
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply