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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query help

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-03-23 : 03:01:16
Dear Experts,

I've two tables.......tab1 and tab2

in tab1, columns are a,b
in tab2, columns are c,d

now, datatypes are all same(varchar)

now my problem is, if the data in column a and column d is same, the data in column c should be there in column b.

that means, the data should be automatically updated in column b if the columns a and d are equal.

please help me in this regard

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-23 : 03:26:10
[code]Update t1
set b = c
From Tab1 t1 join Tab2 t2
on t1.a = t2.d[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-03-23 : 04:25:14
Thank you Harsha

Vinod
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-03-23 : 04:56:20
and one more thing harsha, can you please tell me the trigger to fire whenever an insertion or updation takes place on these two tables.?

thank you very much

Vinod
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-23 : 04:58:35
1. My name is not Harsha, it's Harsh
2. Write an Insert/Update trigger on those table

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-23 : 05:06:51
quote:
Originally posted by sunsanvin

and one more thing harsha, can you please tell me the trigger to fire whenever an insertion or updation takes place on these two tables.?

thank you very much

Vinod


You can refer to this article for more info
http://www.sqlteam.com/item.asp?ItemID=3850


KH

Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-03-23 : 05:12:19
sorry harsh

and thank you for the responce KH

Vinod
Go to Top of Page
   

- Advertisement -