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.
| Author |
Topic |
|
jesus4u
Posting Yak Master
204 Posts |
Posted - 2002-08-20 : 10:44:33
|
| I have never written a trigger but is there a trigger that can detect on INSERT if dups are being written to the table? IF so can you please post a code example?Thanks |
|
|
jesus4u
Posting Yak Master
204 Posts |
Posted - 2002-08-20 : 11:01:18
|
well what I did was check for existing records on the insert DECLARE @C int SELECT @C = count(*) FROM Responses WHERE Gid = @Gid AND msg = @msg AND Qid = @Qid AND ViewID = @ViewID IF @C = 0 But is that an efficient way of doing things?Thanks |
 |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2002-08-20 : 11:17:35
|
| No, ratherif exists (select 1 from join table2 on table1.componentid = table2.componentID )begin-- codeendWhy can't you add a unique constraint to the table instead? |
 |
|
|
jesus4u
Posting Yak Master
204 Posts |
Posted - 2002-08-20 : 11:26:29
|
quote: No, ratherif exists (select 1 from join table2 on table1.componentid = table2.componentID )begin-- codeendWhy can't you add a unique constraint to the table instead?
Wouldn't it be if NOT exists unique constraint? Never heard of it. |
 |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
|
|
|
|
|