Our use of cookies

We use cookies to tailor your experience, gather analytics, and provide you with live assitance. By clicking "Accept" or continuing to browse our site you agree to the use of cookies. For more details please read our Cookie Policy.

Access live SharePoint data from SQL Server

In this blog, We will take an in-depth look into how SQList transforms SharePoint lists into SQL tables and how it stores data into each column. We will also look at how all changes made in SharePoint are continuously synchronized into their corresponding SQL Server tables.

Scenario

Replication of SharePoint lists data into SQL Server database and analysis of the columns created in SQL table for the respective SharePoint list columns of various types, including choice, currency, single-lookup, and multi-lookup columns.

If you would rather watch a video, this tutorial is also available on our YouTube channel at: https://youtu.be/MFXrrlZ5tAA

SharePoint Lists

For this demo, we will use three custom lists with some data in SharePoint Online.

Product list

  • This list contains all the product data.
  • Columns
    • Title (Single Line of Text)
    • Unit Price (Money)
    • Current Stock (Number)
    • Category ID (single-lookup column linked to category list).

Invoice List

  • It is a custom list that contains data of the invoices created for product orders.
  • Columns
    • Title (Single Line of Text)
    • Customer ID (lookup column linked to a Customer list).
    • Product IDs (multi-lookup column linked to Products list).
    • Total Amount (Currency)

Customer List

  • It is a picture library used to store details of all the customers.
  • Columns
    • Title (Single Line of Text)

Step-1: Create a Database in SQL Server

First off, we need a database that will be used for replicating the data coming from SharePoint lists.

Open SQL Server Management Studio and create a new database named “AxioDemoSpColumns”.

 

Step-2: Replicate and Synchronize data to Database

Secondly, we need to replicate the data from SharePoint lists into SQL Server database. We will use SQList to achieve that.

 

Open SQList Manager and click on “Create a new replication”.

 

Create a new SharePoint connection, enter the connection name and Table prefix “AxioDemoLists”

and select the SharePoint site which contains the lists and clicks next.

 

The next step is to select the replication lists, we will select the 3 lists which are going to be used for this exercise i.e. Product, Invoice and Customer.

 

Next, enter the details for the destination SQL database connection which is the database we created earlier.

 

Last step is to give this replication a name, and keep the default options as checked and then click finish.

Once the replication is created, SQList replication service will start off for synchronizing the SharePoint lists and SQL database.

Once the service is started, you will see that some tables have been created in the destination database including the tables for the lists which we selected.

Note: SQList will keep the database in-sync with the SharePoint lists which means any updates made in the lists will be replicated in this database as well.

Step-3: Comparison of SharePoint List Columns and SQL Columns

Now, let’s look at how the Sharepoint lists and columns are transformed into SQL tables and SQL columns.

First off, there is a table created for each list.

In addition to that, a table has been created for each lookup column as well which will store the ID of the parent list (Invoice) item and the value of lookup (Customer) column. For multiple-values selected, there will be multiple rows for each (Product) item selected.

To understand how the SQList creates SQL data tables for the SharePoint lists, Lets to do the comparison of Invoice and product List columns in SharePoint List and SQL table.

Below is the table to show the conversion of sharepoint list columns into sql data columns.

For each lookup column with “Allow multiple values” selected, SQList creates a separate SQL table which stores the ID of the parent list item and the lookup item ID/s creating a one to many relationships between parent and child tables. Since the Invoice list has a lookup column “Product IDs” with allow multiple values checked, a table  “AxioDemoLists_Invoices_ProductIDs” is created.

Now, let’s compare the date in SharePoint List and SQL table to see how data is replicated by SQList in the SQL table. We will also join the Products, ProductIDs and Customer tables to get the lookup values.

 

The result shows that for each invoice item, there are multiple no of rows returned based on the no of products associated to that invoice. but apart from that, the data is stored in an identical fashion.

Now to test the synchronization, let’s go to SharePoint and add a new invoice “Demo Invoice” with three products. when we run the query again, we will three new rows are returned for the new invoice item.

Conclusion

To summarize, today we saw:

  • how SQList transforms SharePoint List into a set of normalised SQL tables;
  • what types of data columns are created against each SharePoint list column;
  • how replicated data are stored in SQL tables using SQL column types that most closely match the types of thecorresponsing CharePoint columns;
  • how multi-lookup columns are stores in auto-generated relational tables that allows the many-2-many relationships between the main and lookup tables.

Latest articles

AxioWorks Newsletter September 2023: An exhilarating month.

30 Sep 2023

Hello Reader, September has been a bustling and exhilarating month for us at AxioWorks, filled with advancements, collaborations, and a whole lot of […]
[read article]

The Collaborative Pathway: Bridging Minds in the AI Ecosystem

19 Sep 2023

In recent days, I found myself immersed in an enlightening conversation with a friend, a fellow entrepreneur steering his ship in the vast sea of […]
[read article]

AxioWorks Newsletter August 2023: A month of milestones and innovation.

28 Aug 2023

Hello Reader, September seems to be a month of unexpected milestones and continued innovations at AxioWorks. As the summer wanes and the autumn […]
[read article]

Use Graph API in Power Automate to read large Excel files from SharePoint

28 Aug 2023

Power Automate, a part of Microsoft’s suite of tools, is increasingly becoming a preferred choice for automating workflows and business […]
[read article]

From Punch Cards to Python: Still Hitting the Keys in my 50s

16 Aug 2023

I spent the entire weekend writing code, not because of deadlines to meet or million-pound dreams, but for the kick that I still get from doing it. […]
[read article]

AxioWorks Newsletter July 2023: Unveiling AxioWorks’s latest successes and exciting innovations

27 Jul 2023

Hello Reader, We hope this monthly update finds you in good spirits. As always, we are eager to share the latest developments and exciting ventures […]
[read article]

AI and Data: The Symbiosis of Interaction and Accuracy

13 Jul 2023

Artificial Intelligence (AI) has rapidly emerged as a revolutionary technology that fundamentally alters the nature of human-machine interactions. […]
[read article]

AxioWorks Newsletter June 2023: SQList v8 Release, Webinars, and New Product Development

30 Jun 2023

Hello Reader, Greetings to all our valued customers and subscribers! We are thrilled to share some exciting updates and developments with you in this […]
[read article]

Safeguarding Secrets with Secure Strings and Environment Variables in the Power Platform

26 Jun 2023

In today’s interconnected digital landscape, safeguarding sensitive information and maintaining robust security measures is of paramount […]
[read article]

Case study: Streamlining Medical Trial Data Analysis in the Pharmaceutical industry

15 Jun 2023

In the ever-evolving landscape of the pharmaceutical industry, conducting medical trials and analysing the resulting data are critical for the […]
[read article]

Get SharePoint and SQL news to your inbox

Stay up-to-date with industry news and trends, SQL and SharePoint innovations and all the latest from AxioWorks by subscribing to our monthly newsletter.

Subscribe to the AxioWorks newsletter

*