April 4, 2011 at 7:30 pm
Create Table Table1
(
IDVARCHAR(20),
ORDER_IDVARCHAR(20)
)
CREATE TABLE TABLE2
(
IDVARCHAR(20),
LOC_IDVARCHAR(20)
)
INSERT INTO Table1
VALUES ('1','CRB-123')
GO
INSERT INTO Table1
VALUES ('2','CRB-345')
GO
INSERT INTO Table1
VALUES ('1','CRB-678')
GO
INSERT INTO TABLE2
VALUES ('1','57')
GO
INSERT INTO TABLE2
VALUES('2','57')
GO
INSERT INTO TABLE2
VALUES('1','57')
GO
--USING UPDATE STATMENT
UPDATE TABLE2
SET LOC_ID = Table1.ORDER_ID
FROM TABLE2
INNER JOIN TABLE1
ON TABLE2.ID = Table1.ID
I am getting this result
ID LOC_ID
1CRB-123
2CRB-345
1CRB-123
I want to be result like this after i run update statement
ID LOC_ID
1CRB-123
2CRB-345
1CRB-678
Please let me know how i can fix this problem.
2) How i can create Parent/Child package(in SSIS), so at the same time i can insert Table1.ORDER_ID and Table2.LOC_ID. Any advise?
April 6, 2011 at 12:38 am
2) How i can create Parent/Child package(in SSIS), so at the same time i can insert Table1.ORDER_ID and Table2.LOC_ID. Any advise?
Hey rocky,
What is the need to create child package for doing this? You can achieve the same by dropping 2 Execute SQL Task on to your SSIS control flow surface and write the insert statement on that.
I am assuming that you are willing to run two insert statement in parallel.
__________________________________________
---------------------------------------------------
Save our mother Earth. Go Green !!!
April 6, 2011 at 12:58 am
I dont think update statement will work like the way you wanted it to as rows are duplicated & it will update the record with 1st occurrence every time you run it.
Is it possible that you can create a PK, FK relation b/w these two table so that you can identify the rows uniquely?
__________________________________________
---------------------------------------------------
Save our mother Earth. Go Green !!!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply