RE: use of host_name( ) in triggers
From: Simon Su (yqsu@onlinemicrosoft.com)
Date: 06/03/02
- Next message: Richard Waymire [MS]: "Re: MS SQL Server 2000 SP2 AV problem with pwdencrypt: possible buffer overflow"
- Previous message: chris: "Re: Pass in NT Username and Password for connection"
- In reply to: Ida: "use of host_name( ) in triggers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: yqsu@onlinemicrosoft.com (Simon Su (MS)) Date: Mon, 03 Jun 2002 02:04:44 GMT
Dear Ida,
I don't know what version of SQL Server you are using and what does your
code look like. I would like give you a simple example here. Please try it,
and modify the codes according to your need. Hope this helps.
create table ##temp_table (login varchar(20),computer
varchar(50),date_and_time varchar(100))
create table abc(id int)
insert into abc(id)
values(1)
insert into abc(id)
values(2)
insert into abc(id)
values(3)
insert into abc(id)
values(4)
create trigger tr_abc
on abc
for update
as
insert into ##temp_table(login,computer,date_and_time)
values(system_user,host_name(),getdate())
NOTE: The temporary table should be a global table.
Regards,
Simon Su (MS)
-----------------------------
This posting is provided Ħ°AS ISĦħ with no warranties, and confers no rights
--------------------
>Content-Class: urn:content-classes:message
>From: "Ida" <idapay@yahoo.com>
>Sender: "Ida" <idapay@yahoo.com>
>Subject: use of host_name( ) in triggers
>Date: Tue, 28 May 2002 00:40:40 -0700
>Lines: 23
>Message-ID: <7d1801c2061a$f6f2f870$a5e62ecf@tkmsftngxa07>
>MIME-Version: 1.0
>Hello! =)
>
>I need to find out who is making scrupulous changes in one
>of the database tables. What I did was to create a trigger
>for an update event for the affected table. This table
>should populate a temporary table that will record the
>login, computer name and date (using SYSTEM_USER, HOST_NAME
>() and GETDATE() ) in which the changes were made.
>
>My problem is if the host_name is used within the trigger,
>the record in the temporary table will have a NULL value
>for the host_name. However, if I run "SELECT HOST_NAME()
>from the query analyzer, the host_name is returned.
>
>Question: What must I do in order to get the desired
>result using HOST_NAME?
>
>I hope to get help from you, guys. Many thanks in advance.
>=)
>
>Kind regards,
>
>Ida
>
- Next message: Richard Waymire [MS]: "Re: MS SQL Server 2000 SP2 AV problem with pwdencrypt: possible buffer overflow"
- Previous message: chris: "Re: Pass in NT Username and Password for connection"
- In reply to: Ida: "use of host_name( ) in triggers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|