Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 trigger
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

programer
Posting Yak Master

Slovenia
221 Posts

Posted - 11/01/2010 :  17:05:49  Show Profile  Reply with Quote
Hi,

I have two table:

Parent Table1:

Id, FirstName

Child Table2

Id, FirstName


In the Parent table FirstName data:
Joe
Mark

The child table FirstName data:
Mark
Joe
Joe
Joe

First table, column FirstName, data = Joe.


How to change data in seconed table, data = Joe.


Instead, Joe, I want Joey to another table.

How to change data in first table, column FirstName, data = Joe,

This is my trigger:

ALTER TRIGGER trg_YourTrigger ON dbo.Table1
FOR UPDATE
AS
UPDATE B.dbo.Table2
SET ColumnY = I.ColumnX
FROM inserted I
INNER JOIN
deleted D
ON I.ID = D.ID
WHERE B.dbo.BB.ColumnY = D.ColumnX


The first table I want to change the FirstName and writes this:

No row was updated

The data in row1 was not committed
Error Source: .Net SqlClient Data Provider.
Error Message: Invalid object name 'B.dbo.Table2.

khtan
In (Som, Ni, Yak)

Singapore
17689 Posts

Posted - 11/01/2010 :  20:15:00  Show Profile  Reply with Quote

UPDATE B.dbo.Table2
SET ColumnY = I.ColumnX
FROM inserted I
INNER JOIN
deleted D
ON I.ID = D.ID
WHERE B.dbo.BB.ColumnY = D.ColumnX


should that be Table2 instead of BB ?


KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000