Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Update Trigger (Please Help)

0 views
Skip to first unread message

Kevin Frevert

unread,
Aug 30, 2002, 8:30:26 AM8/30/02
to
Harun,

Create a cursor (see Books Online for more info) against the Deleted and
Inserted tables. Unless you've guaranteed only one record at a time
insertion/deletion, always assume multi-record inserts/deletes.

Good luck,
krf

"Harun Bolat" <harun...@kaynet.net> wrote in message
news:3d6f...@newsgroups.borland.com...
> Hi,
> I try to write update trigger on MsSQL server2000 . but I don't know how
> can I manage
> Inserted or Deleted table when more than one rows affected.

Harun Bolat

unread,
Aug 30, 2002, 8:41:46 AM8/30/02
to
Thanks Kevin. I try, It is work

Sunil Furtado

unread,
Aug 30, 2002, 8:57:28 AM8/30/02
to

Am not a SQL Server 2000 user so this pertains to SQL 7.

If you could do the same with deletes and inserts
then its probably worth a try as the cursor option is
heavy on resources.

Something like :

delete from tablelog
from deleted d
where tablelog.number=d.number

insert into tablelog
select * from inserted

Sunil

"Harun Bolat" <harun...@kaynet.net> wrote:
>Hi,
> I try to write update trigger on MsSQL server2000 . but I don't know how
>can I manage
>Inserted or Deleted table when more than one rows affected.

>I try to get values that user update but everytime I get only last row that
>is affected .
>for Example in this stament
> SELECT @NUMBER = NUMBER ,@NAME = NAME, @SURNAME = SURNAME FROM
>INSERTED
>
>all local variable get only last value in the inserted table.
>
>It is so important for me .
>thanks.
>
>CREATE TRIGGER UPDATE_TRG ON TABLE1
>FOR UPDATE
>AS
> DECLARE
> @NUMBER INTEGER,
> @OLDNUMBER INTEGER,
> @NAME VARCHAR(20),
> @SURNAM VARCHAR(20),
>
> SELECT @NUMBER = NUMBER ,@NAME = NAME, @SURNAME = SURNAME FROM
>INSERTED
>
> SELECT @OLDNUMBER = NUMBER FROM DELETED
>
> UPDATE TABLELOG SET NAME = @NAME, SURNAME = @SOYADI, NUMBER = @NUMBER
> WHERE NUMBER = @OLDNUMBER
>
>END
>
>
>

Sunil Furtado

unread,
Aug 30, 2002, 9:00:01 AM8/30/02
to

Hello Kevin,

Am not a SQL Server 2000 user, but does not SQL Server 2000
support row level triggers ?

Ty,

Sunil

Kevin Frevert

unread,
Aug 30, 2002, 10:42:29 AM8/30/02
to
No, but that would be a nice feature. Inside an update trigger, there is an
Update function to check whether or not a field was changed

if Update(FirstName)
...

Not the same thing, but definiatly usable.

krf

"Sunil Furtado" <su...@furtado.de> wrote in message
news:3d6f6c51$1...@newsgroups.borland.com...

0 new messages