Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2004, 05:38 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default Updating Multiple columns from subquery

Hi Experts,

Is it possible to do something like this??

Code:
UPDATE Table1
   SET Table1.Field1 = Table2.Field2,
   Table1.Field2 = Table3.Field2
From Table2
     Inner Join Table3
          On Table2.PK = Table3.PK
Where Table1.Key = Table2.Key
Hope you understand my problem.

Thanks in Advance

Regards
Ganesh
__________________
Regards
Ganesh
http://ganeshprof.blogspot.com
Find your solution here...
 
Old December 9th, 2004, 12:08 PM
Authorized User
 
Join Date: Nov 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is a Template that may help you

UPDATE Table1
SET Table1.Field1 = Table2.Field2,Table1.Field2 = Table3.Field2
FROM Table1 INNER JOIN Table2 ON Table1.Key = Table2.Key
INNER JOIN Table2 ON Table2.Key2 = Table3.Key2
WHERE Table1.Field=[Value] [AND/OR/*] Table2.Field =[Value]

This template is little flexible because you can use any kind of join you want if needed. Hope it helps.
 
Old December 10th, 2004, 12:39 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Thanx Rana

Regards
Ganesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
updating the table from the list view columns Yasho VB Databases Basics 2 July 31st, 2007 02:06 AM
updating individual columns kscase VB Databases Basics 11 May 10th, 2007 03:18 PM
multi-multi-multiple Insert with subquery??? jmjyiannis SQL Server 2000 1 May 5th, 2006 02:20 PM
Updating multiple Rows from multiple fields in ASP vdm_nana SQL Server ASP 0 April 1st, 2004 04:26 AM
Multiple Columns in an Index owain SQL Server 2000 8 June 17th, 2003 03:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.