7 Working with SQL

 

This chapter covers

  • Building SQL databases and tables
  • Inserting and updating data
  • Retrieving data
  • Using data validation before writing to SQL

Anyone who has worked in IT long enough has inevitably received a call from a panicked department head saying that the Excel spreadsheet or Access database the entire department is reliant on has broken. As you investigate, you discover a mess of spaghetti code macros that have been cobbled together over the years. As you are racking your brain trying to reverse engineer it, you keep thinking to yourself, how did this happen?

I have found that these are often the result of one person taking some initiative to try to improve their job—in much the same way an automator thinks. However, before they realized what was happening, the entire department became dependent on what they threw together in their spare time. I am here to tell you this is not just a problem in “other” departments. It happens with IT and with automations as well. And I am also here to show you how not to fall into this trap by learning to use a proper database.

7.1 Setting your schema

7.1.1 Data types

7.2 Connecting to SQL

7.2.1 Permissions

7.3 Adding data to a table

7.3.1 String validation

7.3.2 Inserting data to a table

7.4 Getting data from a table

7.4.1 SQL where clause

7.5 Updating records

7.5.1 Passing pipeline data

7.6 Keeping data in sync

7.6.1 Getting server data

7.7 Setting a solid foundation

Summary