Preview Content - log in or Buy Access Pass

SQL Update

Hi

In this tutorial I will give you example of SQL Update queries which will include SQL update join examples. I will use SQL Server 2008 R2 for my samples which should work with previous version of SQL Server without any problems.

Contents

SQL Update Overview


SQL Update is used to update one table columns with specified values. You can update one or multiple columns at the same time. For instance you might want to update customer address and this case you would update several columns like AddressLine1, AddressLine2, City, Post code with usually either hard coded or provided values from end user application. You could also update values using calculated fields for instance you might want to update Employee holiday entitlement (once a year) and you could use Employee start date to calculate number of years that employee has worked for the company and use some "IF" (case in SQL) logic to specify the correct holiday entitlement. Very often you might want to perform updates using another related table and for instance in our Holiday entitlement case we could use a HolidayEntitlement table and match it against our YearsWorked that could be calculated using EmployeeStartDate and provide matching row (HolidayEntitlement) from related HolidayEntitlement table. This SQL Update Join that I will give you examples of but be careful with joins this method can be tricky and I will give examples when it can go wrong. Apart from specifing or matching rows in SQL Update the most common task is to specify correct filter (or join) so we update only the rows with values we want to affect. Below I will provide you with simple syntax and later on provide you examples that will cover types of updates I mentioned.

SQL Update Syntax

Below I will give you basic and most popular example of SQL Update syntax which should work in most cases but there are more complicated syntaxes and I will show them to you with examples and screenshots later in this section.

 

To access members only content...
Log in (active member) or buy Access Pass
Learn as much as you like
Unlimited learning access pass*
* Secure one off payment, no re-occuring payments, no surprises
T-SQL SSIS SSRS 79 Mini Courses 529 Pages 287 Videos 314 Articles
Forum Live Webinars 12 Webinar Recordings DIY Projects Progress Tracking
New member joins every 8 hours
   

60 days, 100% money back guarantee
NO risks, NO questions asked, NO hard feelings

I can't speak highly enough of the quality MSBI materials industry practitioners with varying level of experience and exposure can benefit from this website. Their structured learning plan and courses, DIY projects, webinars and relevant resources go a very long way. I've gained a whole new perspective on delivering client BI projects to highest standards by employing best practices recommended on this website. Best quality MSBI training online suite I have used and least expensive too.

Franklin Demilade Osinowo

Best and affordable BI Training platform in the web. KEBI Academy doesn't provide training on BI rather their approach is to make you learn BI by yourself. Self Learning is always the best approach and I recommend KEBI Academy.

Jaiyaram Mahendran


You both are doing a great job by sharing your knowledge and experience, it helps many people who want to learn MSBI from the starting point and also for an experienced person to get to know more about MSBI. Thank you and keep sharing your MSBI knowledge and experience.

Shweta Patel

Great work on the videos. I have been enjoying them.

Patt Nelson


Did you find this page useful?
+5  |  -0
(5 Votes)