Home > Archive > MS SQL Server > March 2006 > stored procedure for update









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author stored procedure for update
Jason Huang

2006-03-23, 3:25 am

Hi,

I wanna write a Stored Procedure ( NOT Trigger) for updating tables.
So if CustomerName updated in table CustomerA, it will then update in
CustomerB.
Would some tell me how to do this?
Thanks for help.


Jason


Jens

2006-03-23, 3:25 am

There is no automatism to that that other than the server are some
client functionalities like query notification in SQL Server 2005. You
could do an update in another table where a job , which runs an a
second or 10 second basis check for entries and does the same work as
the trigger, but this would be like reinventing the wheel. Why are you
concerned about using triggers here ?

HTH, Jens Suessmeyer.

---
http://www.sqlserver2005.de
---

Uri Dimant

2006-03-23, 3:25 am

Jason


UPDATE CustomerB SET CustomerName =(SEELCT CustomerName FROM
CustomerA WHERE CustomerA. CustomerID=CustomerB
.CustomerID AND
CustomerA.CustomerName <>CustomerB.CustomerName )
WHERE EXISTS (SELECT * FROM
CustomerA WHERE CustomerA. CustomerID=CustomerB
.CustomerID AND
CustomerA.CustomerName <>CustomerB.CustomerName)

---or


UPDATE CustomerB SET CustomerName =A.CustomerName FROM
CustomerA A JOIN CustomerB ON A. CustomerID=CustomerB
.CustomerID
AND A.CustomerName <>CustomerB.CustomerName

"Jason Huang" < JasonHuang8888@hotma
il.com> wrote in message
news:%235FdfFlTGHA.4384@tk2msftngp13.phx.gbl...
> Hi,
>
> I wanna write a Stored Procedure ( NOT Trigger) for updating tables.
> So if CustomerName updated in table CustomerA, it will then update in
> CustomerB.
> Would some tell me how to do this?
> Thanks for help.
>
>
> Jason
>



Jason Huang

2006-03-25, 3:23 am

Thanks Uri.

"Uri Dimant" <urid@iscar.co.il> ¼¶¼g©ó¶l¥ó·s»D:ujhHb
MlTGHA.5332@tk2msftngp13.phx.gbl...
> Jason
>
>
> UPDATE CustomerB SET CustomerName =(SEELCT CustomerName FROM
> CustomerA WHERE CustomerA. CustomerID=CustomerB
.CustomerID AND
> CustomerA.CustomerName <>CustomerB.CustomerName )
> WHERE EXISTS (SELECT * FROM
> CustomerA WHERE CustomerA. CustomerID=CustomerB
.CustomerID AND
> CustomerA.CustomerName <>CustomerB.CustomerName)
>
> ---or
>
>
> UPDATE CustomerB SET CustomerName =A.CustomerName FROM
> CustomerA A JOIN CustomerB ON A. CustomerID=CustomerB
.CustomerID
> AND A.CustomerName <>CustomerB.CustomerName
>
> "Jason Huang" < JasonHuang8888@hotma
il.com> wrote in message
> news:%235FdfFlTGHA.4384@tk2msftngp13.phx.gbl...
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com