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)
 deletions for 3 tables

Author  Topic 

rjhe22
Constraint Violating Yak Guru

283 Posts

Posted - 2010-06-17 : 12:37:04
hi i have to delete wrong entries frm three different table
i was asked to do it the way i have it done but am wondering if this code makes sense and if it looks like its right

( @bankImportID uniqueidentifier
@valuationPriceID uniqueidentifier)
AS



--bank import journal level
DECLARE @tbl TABLE
( BankImportID uniqueidentifier ,
ValuationPriceID uniqueidentifier )

INSERT INTO @tbl
( BankImportID )
SELECT bij
FROM dbo.BankImportJournal bij
WHERE bij.BankImportID = @bankImportID

INSERT INTO @tbl
( ValuationPriceID )
SELECT vp
FROM dbo.ValuationPrice vp
WHERE vp.ValuationPriceID = @valuationPriceID

--Delete bank import
--Journal
DELETE bij
FROM dbo.BankImportJournal bij
INNER
JOIN @tbl t
ON t.BankImportID = bij.BankImportID

-- delete from bank import log
DELETE bil
FROM dbo.BankImportLog
WHERE BankImportID = @bankImportID

DELETE vp
FROM dbo.ValuationPrice
WHERE ValuationPriceID = @valuationPriceID

rjhe22
Constraint Violating Yak Guru

283 Posts

Posted - 2010-06-17 : 13:05:55
anyone any idea need to get this finished this evening
Go to Top of Page
   

- Advertisement -