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 2000 Forums
 Transact-SQL (2000)
 UPdate Question

Author  Topic 

azwiefel
Starting Member

7 Posts

Posted - 2003-09-01 : 15:14:36
Help, attached is a SP that I;m tring to get fuctioning... I'm sure the syntax is incorrect based on what I am reading...
Basicly, I am tring to updated a table that is used as a reference table for a group of orders, each peice of equipment may have serveral "Counters" and the end number must be written back to this table after the order is closed out.

CREATE PROCEDURE TEST
(
@equipmentID int,
@transID BigINT,
@modifiedBy int
)
AS

Update dbo.equipment_Counters
SET
(counterStartCount,
countermodifedBy,
counterModifiedDate)
VALUES
(SELECT
endCount,
@modifiedby,
Getdate()
FROM
dbo.TRANSACTIONS
INNER JOIN
dbo.TRANSACTIONS_EquipmentCounters
ON
dbo.TRANSACTIONS.transID =dbo.TRANSACTIONS_EquipmentCounters.transID
AND
dbo.TRANSACTIONS.siteID = dbo.TRANSACTIONS_EquipmentCounters.siteID
WHERE
(dbo.TRANSACTIONS_EquipmentCounters.transID = @transID)
AND
(dbo.TRANSACTIONS.EquipmentID = @equipmentID))
GO

I would like to do this with minimum overhead and coding..

Thanks for everyones help...

nr
SQLTeam MVY

12543 Posts

Posted - 2003-09-01 : 15:26:49
update tbl
set col1 = t2.col1 ,
col2 = t2.col2
from tbl
join t2
on ...
join ...
where ...

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -