Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have this sql working ok:SELECT pc.ProductCode_ID, pc.ProductCode, CASE WHEN EXISTS (SELECT ProductCodeRef_ID FROM ProductCodeRef WHERE ProductCode = pc.ProductCode_ID AND BusinessPartner = @BP) THEN 1 ELSE 0 END 'Active'FROM ProductCode pcI now need to add another field somehow. The field name is zones and is in the ProductCodeRef table. This is an int.I need all records from ProductCode then mark each row as active or not. Now I need the other field in there.Suggestions?Thanks,Zath
SELECT pc.ProductCode_ID, pc.ProductCode, CASE WHEN PCR.ProductCodeRef_ID IS NULL THEN 0 ELSE 1 END AS [Active], PCR.zones FROM ProductCode AS pc LEFT OUTER JOIN ProductCodeRef AS PCR ON PCR.ProductCode = pc.ProductCode_ID AND PCR.BusinessPartner = @BP