Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2003
    Location
    Recife - PE - Brazil
    Posts
    28

    Post Key column information is insufficient or incorrect. Too many...

    Hi,

    Im trying to Update a table called Contratos in the field Cliente from the table Clientes with the field Cliente.

    Im using the follow Trigger :

    CREATE TRIGGER UPDate_Clientes ON dbo.Clientes
    FOR UPDATE
    AS
    update Contratos
    set Cliente = inserted.Cliente
    from Clientes
    inner join inserted on Clientes.Cliente = inserted.Cliente

    When I update the register the follow message in the application raise :

    "Key column information is insufficient or incorrect. Too many rows were affected by update."

    What is happen...Can somebody help me?

    Leonardo Almeida

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: Key column information is insufficient or incorrect. Too many...

    Originally posted by vectords
    Hi,

    Im trying to Update a table called Contratos in the field Cliente from the table Clientes with the field Cliente.

    Im using the follow Trigger :

    CREATE TRIGGER UPDate_Clientes ON dbo.Clientes
    FOR UPDATE
    AS
    update Contratos
    set Cliente = inserted.Cliente
    from Clientes
    inner join inserted on Clientes.Cliente = inserted.Cliente

    When I update the register the follow message in the application raise :

    "Key column information is insufficient or incorrect. Too many rows were affected by update."

    What is happen...Can somebody help me?

    Leonardo Almeida
    Where is relation between Contratos and Clientes?

  3. #3
    Join Date
    Sep 2003
    Location
    Recife - PE - Brazil
    Posts
    28

    Exclamation Key column information is insufficient or incorrect. Too many...

    This is the case.... I would like to learn the statement that make the relation between these tables.
    Why? Cos these are separated in two different databases and if a user make an update in a table from database X these changes must to be applied in the other table in the another database:

    The tables are :

    Principal Database Name : Server Information 2004
    Table Name : Clients
    Fields : ID_Client, Client

    Secondary Database Name : Index2003
    Table Name : Contratos
    Fields : ID_Con, ID_Client, Client

    I need to write a Trigger for Update the table Contratos everytime a user change the values in Clients.

    Im using the follow Trigger :

    CREATE TRIGGER UPDate_Clients ON dbo.Clients
    FOR UPDATE
    AS
    update Contratos
    set Client = inserted.Client
    from Clients
    inner join inserted on Clients.Client = inserted.Client

    When I update the register the follow message in the application raise :

    "Key column information is insufficient or incorrect. Too many rows were affected by update."

    If somebody can help me THANKS A LOT OF....

    Leonardo Almeida

  4. #4
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Talking Re: Key column information is insufficient or incorrect. Too many...

    Try this one:

    CREATE TRIGGER UPDate_Clients ON dbo.Clients
    FOR UPDATE
    AS
    update Contratos
    set Client = inserted.Client
    from inserted on Contratos.ID_Client = inserted.ID_Client

    ------------------------
    Only because of Pele

  5. #5
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: Key column information is insufficient or incorrect. Too many...

    Originally posted by vectords
    This is the case.... I would like to learn the statement that make the relation between these tables.
    Why? Cos these are separated in two different databases and if a user make an update in a table from database X these changes must to be applied in the other table in the another database:

    The tables are :

    Principal Database Name : Server Information 2004
    Table Name : Clients
    Fields : ID_Client, Client

    Secondary Database Name : Index2003
    Table Name : Contratos
    Fields : ID_Con, ID_Client, Client

    I need to write a Trigger for Update the table Contratos everytime a user change the values in Clients.

    Im using the follow Trigger :

    CREATE TRIGGER UPDate_Clients ON dbo.Clients
    FOR UPDATE
    AS
    update Contratos
    set Client = inserted.Client
    from Clients
    inner join inserted on Clients.Client = inserted.Client

    When I update the register the follow message in the application raise :

    "Key column information is insufficient or incorrect. Too many rows were affected by update."

    If somebody can help me THANKS A LOT OF....

    Leonardo Almeida
    Do every table have a primary key? If no - create primary keys...

  6. #6
    Join Date
    Sep 2003
    Location
    Recife - PE - Brazil
    Posts
    28

    Lightbulb

    Yes ... each table has the primary key

    ID_Client for Clients
    ID_Con for Contratos

  7. #7
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    This is working:

    create table table1(id int primary key,uname varchar(10))
    create table table2(id int primary key,id_2 int,uname varchar(10))
    go
    create trigger i_table1 on table1
    for update
    as
    update table2
    set uname=inserted.uname
    from inserted where table2.id_2=inserted.id
    go
    insert table1 select 1,'test'
    insert table2 select 1,1,'test'
    go
    update table1 set uname='test2' where id=1
    select * from table1
    select * from table2

    Try to find error in your script.

  8. #8
    Join Date
    Sep 2003
    Location
    Recife - PE - Brazil
    Posts
    28

    Exclamation

    Thank you very much....
    Can you send me your e-mail to leonardoalmeida2004@yahoo.com.br to me give back a return from whats happen to my database I will put this struture you send me in my database and tables

    THANK YOU VERY MUCH.

    Leonardo Almeida

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •