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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Update data

Author  Topic 

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2004-08-25 : 00:28:42
Hi All,

I have two tables:-


Create table #x(a int, b int,c int)

Insert into #x
SELECT 1,1,1
UNION ALL
SELECT 2,2,2
UNION ALL
SELECT 3,3,3
UNION ALL
SELECT 4,4,4

Create table #y(a int, b int,c int)
Insert into #y
SELECT 1,1,111
UNION ALL
SELECT 2,2,222

select * from #x
select * from #y

drop table #x
drop table #y

How to update column #x.c with #y.c where #x.a=#y.a and #x.b=#y.b

Thanks

mk_garg

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-08-25 : 00:54:34
UPDATE #x
SET #x.c = #y.c
FROM #x, #y
WHERE #x.a = #y.a and #x.b = #y.b
Go to Top of Page

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2004-08-25 : 01:25:36
Thanks

mk_garg
Go to Top of Page
   

- Advertisement -