From the course: Complete Guide to Advanced SQL Server

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Create updatable ledger tables

Create updatable ledger tables

Now that we know some of the details about how the ledger feature works in SQL Server, let's see it in action. I've got a fresh installation of SQL Server 2022 here, and I've opened up the updatable ledger table SQL file that you can find in the course exercises. First, I'm going to do a little housekeeping and set up a new database for a company named KinetEco. Then I'll switch my context into that database and create a schema to hold our finance data. Let me just execute lines one through eight and we'll move down to set up our updatable ledger table. It starts with the standard CREATE TABLE statement. This table will hold account information for our customers and it includes their customer ID, their name, and their current balance. Next, we need to configure a couple of parameters for the table. And that happens after the WITH keyword. The updatable ledger table requires a companion history table. So we'll set that up by setting system versioning to on. And then I'll name the…

Contents