If you use DELETE is deletes the entire row, not the specified filed. If you
just want to NULL the field use UPDATE SET CUSTOMERS = NULL WHERE ID=5;.
I would suggest using INSTED OF TRIGGER (INSTEAD OF DELETE ...), look
http://msdn.microsoft.com/library/de...es_08_49kj.asp.
To pass arguments to TRIGGER you have two tables deleted and inserted which
you can use (in some database system NEW and OLD as new and old record),
look
http://msdn.microsoft.com/library/de...es_08_0lo3.asp.
Hope it helps. If something is unclear, make a reply.
"Gregory Dean" <gdean@datapex.com> wrote in message
news:BE3047C0.4779%gdean@datapex.com...[color=blue]
> On 2/9/05 10:32 PM, in article
>
1108006343.442733.104310@f14g2000cwb.googlegroups. com, "WertmanTheMad"
> <cwertman@webchamps.com> wrote:
>[color=green]
>> Ok here goes, another odd SQL Question ....as always..
>>
>> How do I get ...
>> The value of a paramater passed to say a Trigger
>> OR The SQL Itself
>>
>> Like this , say I have a Trigger set on delete,
>>
>> Now this trigger will add a row to another table (a history table) but
>> it need to be passed a paramater, throught the sql itself as it cannot
>> be any different than a normal delete so it would go something like
>> this
>>
>> delete from customers where id=5 and user='chris'
>>
>> Now all that is needed to delete from customers is the id
>>
>> So in my delete trigger I want to parse off the user and actually use
>> it as a value in the insert for the history table
>>
>> So in the actual delete trigger itself it would get the " and
>> user='chris' " stripped off an the delete would just be
>>
>> delete from customers where id=5
>>
>> I would then use the user='chris' in the insert of the history table.
>>
>> I cant really use a sproc, as the code calling this cant easily be
>> changed, but I still need to do this on the delete.
>>
>> SO , How can I get the value of user , OR The whole sql that is causing
>> the trigger to fire ?
>>
>> Many Thanks
>>
>> Chris Wertman
>>[/color]
>
> All you really need to do in the delete trigger is query deleted data for
> the fields you would like to use in your insert statement...
>
> DECLARE @user varchar(16)
> SELECT @user = user FROM deleted
> INSERT INTO history (user, deleteddate) VALUES (@user, GETDATE())
>
> -Greg
>[/color]