Soluga
asked on
sql select and insert from the same table
HI,
I have the code below but it creates duplicates.
I want to be able to select the values from the mastercompany and insert it into the same table but with a different company id.
Would be grateful for any advice
Insert into tbl_M08_PageObjectLangCont ent
(pageObjLangContId, objectId, companyId, sysLanguageId, objectText, objectAlign, createdBy, createdDate, lastModifiedBy, lastModifiedDate)
(SELECT newid(), objectId, 'c6a21d21-a55a-4d50-a4a7-1 0c5a746460 d', sysLanguageId, objectText, objectAlign, 'b81ff3cc-811f-49c8-ab22-9 d9fc377d0f 5', createdDate, 'b81ff3cc-811f-49c8-ab22-9 d9fc377d0f 5', lastModifiedDate
FROM tbl_M08_PageObjectLangCont ent
WHERE companyId = '141a9a54-a3ab-440f-91c1-3 8eb16310b2 6')
I have the code below but it creates duplicates.
I want to be able to select the values from the mastercompany and insert it into the same table but with a different company id.
Would be grateful for any advice
Insert into tbl_M08_PageObjectLangCont
(pageObjLangContId, objectId, companyId, sysLanguageId, objectText, objectAlign, createdBy, createdDate, lastModifiedBy, lastModifiedDate)
(SELECT newid(), objectId, 'c6a21d21-a55a-4d50-a4a7-1
FROM tbl_M08_PageObjectLangCont
WHERE companyId = '141a9a54-a3ab-440f-91c1-3
instead of selecting companyID from the table, this is where you would add the new companyid that you want the record to have.. is the new company id available in a table, if so select it from there
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's great thanks