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

 All Forums
 SQL Server 2012 Forums
 SSIS and Import/Export (2012)
 Merge Rows in SQL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tooba
Posting Yak Master

143 Posts

Posted - 12/23/2013 :  18:25:50  Show Profile  Reply with Quote
Here is my Test Data, Please any advise would be great appreciated.


CREATE TABLE Table1

(

ID NVARCHAR(50),

FName NVARCHAR(50),

LName NVARCHAR(50),

DOB NVARCHAR(50),

Active bit

)



Create Table Table2

(

ID NVARCHAR(50),

PID NVARCHAR(50),

Phone NVARCHAR(50),

Address NVARCHAR(50)

)

Create TABLE Tbale3

(

PID NVARCHAR(50),

OInfo NVARCHAR(50)

)



--Insert Table1

Insert into Table1 (ID,FNAME,LName,DOB)

VALUES ('1','Smith','Tom','12/12/2011')



Insert into Table1 (ID,FNAME,LName,DOB)

VALUES ('2','Smith','Tom','12/12/2011')



--Insert Table2

Insert into Table2 (ID,PID,PHONE,Address)

VALUES ('1','101','5178896566','Test Ave')



-- Insert Table3

Insert Into Tbale3

VALUES ('101','Active Order')



-- Here is my question....



I am Creating a Front End for this, the user is going to SELECT Witch rows they want to MERGE.

here is the update i need from first table



ID FName LName DOB ISactive

1 Smith Tom 12/12/2011 NULL

2 Smith Tom 12/12/2011 NULL



Let Say user select ID = 1 they wants to merge so I want to update in TABLE1 ISactive = 1 for ID=1

and in TABLE2, update ID = 2, data look like this

ID PID Phone Address

2 101 5178896566 Test Ave


and in TABLE3, UPDATE PID = 101
PID OderInfo
101 Active Order

Please feel free to let me know if my questino is not clear and doesn't make sens. Thanks in advance.
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000