If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back  dBforums > Database Server Software > Microsoft SQL Server > Key column information is insufficient or incorrect. Too many...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
Just DBA
 
Join Date: Jul 2002
Location: Village, MD
Posts: 621
Re: Key column information is insufficient or incorrect. Too many...

Quote:
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?
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old
Just DBA
 
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
Reply With Quote
  #5 (permalink)  
Old
Just DBA
 
Join Date: Jul 2002
Location: Village, MD
Posts: 621
Re: Key column information is insufficient or incorrect. Too many...

Quote:
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...
Reply With Quote
  #6 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #7 (permalink)  
Old
Just DBA
 
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.
Reply With Quote
  #8 (permalink)  
Old
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On