Re: Disallowing/Ignoring Insert based on certain column value

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Harag (haragREMOVETHESECAPITALS_at_softhome.net)
Date: 08/17/04


Date: Tue, 17 Aug 2004 09:05:31 +0100

On Tue, 17 Aug 2004 00:44:13 -0700, "SPhan" <susan@spryersoft.com>
wrote:

>Can anyone help me on writing a trigger that disallows insert into the table
>based on certain condition.
>
>for example if the value that is being inserted in Employee Name column has
>text 'Unknow' then just ignore Insert.
>

Look up triggers, inserted and deleted in Books Online (BOL)

triggers have access to two tables (inserted & deleted)

try something like

delete from inserted where empname = "unknown"

I don't know if the above will work as I've never done anything like
that b4.

HTH

Al.