GaryMans Posted January 23, 2018 Share Posted January 23, 2018 Hi All, I am hoping someone can point me into the right direction with this one. So i have two databases, the one is used to update costings (dbs1) for different products using multiple tables. The other dbs (dbs2) is used to store costings of an existing project I then at the end of my design process use a query to update dbs1 with dbs2. here is the syntax; THIS WORKS... UPDATE SSRevitProject1.dbo.WindowTypes SET Cost = new.Cost FROM SSRevitCostings.dbo.SSParkHomeCostings AS new WHERE SSRevitProject1.dbo.WindowTypes.Model = new.Model THIS DONT WORK... UPDATE SSRevitProject1.dbo.CaseworkTypes SET Cost = new.Cost FROM SSRevitCostings.dbo.SSContainerCostings AS new WHERE SSRevitProject1.dbo.CaseworkTypes.Model = new.Model The problem i have is that SQL is for some reason not using one of my tables in dbs1 to update dbs2. I hope this is clear enough. Link to comment Share on other sites More sharing options...
niche Posted January 23, 2018 Share Posted January 23, 2018 need to do a join https://www.w3schools.com/sql/sql_join.asp Link to comment Share on other sites More sharing options...
GaryMans Posted January 25, 2018 Author Share Posted January 25, 2018 Hi NIche, A little confused as to where i should add the INNER JOIN... THis is what i have... UPDATE SSRevitProject1.dbo.CaseworkTypes SET Cost = new.CostFROM SSRevitCostings.dbo.SSContainerCostings AS newWHERE SSRevitProject1.dbo.CaseworkTypes.Model = new.Model Sorry i am a bit of a newby so if you can point me in the right direction it would be appreciated. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 25, 2018 Share Posted January 25, 2018 The syntax differs based on which database you're using: https://stackoverflow.com/questions/224732/sql-update-from-one-table-to-another-based-on-a-id-match 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