🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.databases.ms-sqlserver
2 messages
2 total messages Started by Tom Mon, 28 Sep 1998 00:00
trigger question for the gurus
#143
Author: Tom
Date: Mon, 28 Sep 1998 00:00
39 lines
2393 bytes
   I have two tables.  One that looks like a normal table we will call it A
has rows and one that looks like a metadata table (called B) which has the
rows transposed to columns.

What I want to be able to do is update table B when ever table A is
Inserted,updated or deleted from.  My problem is that in table B it is not
in a row format but a column format.  I need to capture the column name that
was changed updated or deleted and do the same in column B.  I will need to
do this for each column that is update inserted or deleted from the row in
column A.  Table C stores the names of the columns to update Table B and is
joined on column_id.


Any sample code would be a great help thanks


Example
TABLE :  A
Column Names:        Name         address        city
state
Values for columns:  Jim            somewhere    Beverly Hills    CA


Table: B
Column Name:  Column_id         value
                                1                        Jim
                                 2                        Somewhere
                                3                         Beverly hills
                                4                        CA

TABLE C :  column_id                    name
                            1                                Name
                            2                                Address
                            3                                City
                            4                                State

Thanks

Tom
Re: trigger question for the gurus
#144
Author: Bob Pfeiff
Date: Tue, 29 Sep 1998 00:00
8 lines
990 bytes
You can use If Update in an Update or Insert trigger to test if a column was
changed.  More in books online under "Create Trigger".

Hope this helps.

--
Bob Pfeiff
MCSD, SQL Server MVP
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads