Link to home
Start Free TrialLog in
Avatar of Soluga
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_PageObjectLangContent
(pageObjLangContId, objectId, companyId, sysLanguageId, objectText, objectAlign, createdBy, createdDate, lastModifiedBy, lastModifiedDate)
(SELECT newid(), objectId, 'c6a21d21-a55a-4d50-a4a7-10c5a746460d', sysLanguageId, objectText, objectAlign, 'b81ff3cc-811f-49c8-ab22-9d9fc377d0f5', createdDate, 'b81ff3cc-811f-49c8-ab22-9d9fc377d0f5', lastModifiedDate
FROM tbl_M08_PageObjectLangContent
WHERE companyId = '141a9a54-a3ab-440f-91c1-38eb16310b26')
Avatar of QuinnDex
QuinnDex

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
Avatar of JimFive
JimFive
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Soluga

ASKER

That's great thanks