Click here to Skip to main content
15,897,718 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL Server 2005 Tuning Book Pin
John_Adams11-Dec-07 19:26
John_Adams11-Dec-07 19:26 
Generalint vs smallint Pin
Brendan Vogt11-Dec-07 10:28
Brendan Vogt11-Dec-07 10:28 
GeneralRe: int vs smallint Pin
pmarfleet11-Dec-07 11:02
pmarfleet11-Dec-07 11:02 
GeneralResults Pin
KreativeKai11-Dec-07 8:42
professionalKreativeKai11-Dec-07 8:42 
GeneralRe: Results Pin
pmarfleet11-Dec-07 9:03
pmarfleet11-Dec-07 9:03 
GeneralRe: Results Pin
KreativeKai11-Dec-07 9:27
professionalKreativeKai11-Dec-07 9:27 
GeneralRe: Results Pin
pmarfleet11-Dec-07 10:31
pmarfleet11-Dec-07 10:31 
General[T-SQL] Delete trigger. [modified] Pin
MY120111-Dec-07 2:51
MY120111-Dec-07 2:51 
Hello everybody.

I'm updating an application which makes use of a trigger to maintain relationships between some tables in the database. I was unable to figure out how this could work with a simple constraint, so I thought I would go for a good olde' trigger. Smile | :)

Here's the deal:

I have two tables: A and B, which both depends on information in table C. Now table C contains some binary data, and some information on how this binary data relates between rows in table A and B.

If a row in table A is deleted, all references to that row in table C must also be deleted. The same thing goes for table B. Since entities in table A and B can have the same primary key, the table C use the primary key and a char to determine whether the primary key belongs to table A or B. Therefore I thought a constraint would be out of the question.

The trigger problem:
The problem is the "DELETED" logical table. As one might have guessed, it only works when there is one row in the DELETED table. The system allows the users to delete multiple rows, so I will have to construct the trigger to maintain relationships for all the rows in the DELETED table.

I would most definitely like to avoid using a CURSOR on the DELETED table.

How do I do that? Smile | :)

(Should anyone be able to see how I could construct a constraint for the job, I would also like to know how to do that)

Thanks for any help you can provide! Smile | :)

modified on Monday, March 10, 2008 4:58 AM

GeneralRe: [T-SQL] Delete trigger. Pin
Mark J. Miller11-Dec-07 7:21
Mark J. Miller11-Dec-07 7:21 
GeneralRe: [T-SQL] Delete trigger. [modified] Pin
MY120111-Dec-07 23:18
MY120111-Dec-07 23:18 
QuestionSQL Server 2005 Default Database folder Pin
Steven J Jowett11-Dec-07 1:10
Steven J Jowett11-Dec-07 1:10 
GeneralRe: SQL Server 2005 Default Database folder Pin
Steven J Jowett11-Dec-07 1:14
Steven J Jowett11-Dec-07 1:14 
GeneralGUID - SQL Server 2005 Pin
N a v a n e e t h10-Dec-07 23:32
N a v a n e e t h10-Dec-07 23:32 
GeneralRe: GUID - SQL Server 2005 Pin
SimulationofSai11-Dec-07 0:40
SimulationofSai11-Dec-07 0:40 
GeneralRe: GUID - SQL Server 2005 Pin
Pete O'Hanlon11-Dec-07 9:25
mvePete O'Hanlon11-Dec-07 9:25 
GeneralRe: GUID - SQL Server 2005 Pin
N a v a n e e t h11-Dec-07 16:38
N a v a n e e t h11-Dec-07 16:38 
GeneralRe: GUID - SQL Server 2005 Pin
Pete O'Hanlon12-Dec-07 11:22
mvePete O'Hanlon12-Dec-07 11:22 
GeneralRe: GUID - SQL Server 2005 Pin
Mark Churchill15-Dec-07 18:35
Mark Churchill15-Dec-07 18:35 
GeneralRe: GUID - SQL Server 2005 Pin
N a v a n e e t h15-Dec-07 22:33
N a v a n e e t h15-Dec-07 22:33 
GeneralIdentity column with LINQ to SQL Pin
Brady Kelly10-Dec-07 23:22
Brady Kelly10-Dec-07 23:22 
GeneralRe: Identity column with LINQ to SQL Pin
Brady Kelly11-Dec-07 2:11
Brady Kelly11-Dec-07 2:11 
QuestionPls help: Error converting data type varchar to numeric Pin
masyarial10-Dec-07 15:15
masyarial10-Dec-07 15:15 
GeneralRe: Pls help: Error converting data type varchar to numeric Pin
SimulationofSai10-Dec-07 20:22
SimulationofSai10-Dec-07 20:22 
GeneralRe: Pls help: Error converting data type varchar to numeric Pin
masyarial11-Dec-07 14:48
masyarial11-Dec-07 14:48 
GeneralIdentity Seed vs varchar Pin
Brendan Vogt10-Dec-07 12:23
Brendan Vogt10-Dec-07 12:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.