NewEra13 Posted December 12, 2014 Share Posted December 12, 2014 How to update a table based on a select statement. Please take 5 minutes to see attached file. sql.txt Link to comment Share on other sites More sharing options...
justsomeguy Posted December 12, 2014 Share Posted December 12, 2014 You can use another subquery to find records in one table that aren't in another table. You can use NOT EXISTS or NOT IN for that. Link to comment Share on other sites More sharing options...
NewEra13 Posted December 12, 2014 Author Share Posted December 12, 2014 Thanks ! Link to comment Share on other sites More sharing options...
NewEra13 Posted December 16, 2014 Author Share Posted December 16, 2014 Hello again, By the way could you help me make this update work as for i'm getting the error message: Incorrect syntax near ')' UPDATE dbo.Part SET SupplierShortName = NationalSupplier.ShortName, SupplierLongName = NationalSupplier.LongName from(SELECT * FROM dbo.Part JOIN dbo.NationalSupplier ON Part.SupplierNumber = NationalSupplier.Number AND (ISNULL(Part.SupplierShortName,'') <> ISNULL(NationalSupplier.ShortName,'') OR ISNULL(Part.SupplierLongName,'') <> ISNULL(NationalSupplier.LongName,'')) LEFT OUTER JOIN dbo.NationalPart ON Part.NationalPartID = NationalPart.NationalPartID WHERE Part.DWCreationEntityID = 1 AND NationalPart.NationalPartID is NULL) Link to comment Share on other sites More sharing options...
justsomeguy Posted December 16, 2014 Share Posted December 16, 2014 I'm not very familiar with UPDATE..FROM queries. Which line does it say the error is on? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now