Question

I haven't used SharePoint a great deal, but I have worked with other database systems.

If I have a table in a SharePoint site, how can I connect to it and issue a database query in a similar fashion to how you would do this on MySQL etc? I can find the button to load a SharePoint table in Microsoft Access, so presumably this is possible if I could find the URL to connect to. I'd like to do this to integrate the data held in sharepoint with a workflow tool which can query Databases and produce a report, or ideally post new data back into the database.

I can find resources for how to connect SharePoint to other external databases, but how do you connect to the SharePoint backend database itself?

Was it helpful?

Solution

What you see with Access is more or less the illusion of SQL access to SharePoint data. When you open a list via Access, Access actually queries SharePoint for the structure of the list and builds that as a table in the local access database. It then pulls the data down and populates the local table. Access will maintain the link to the original List and can keep both in Sync, but any queries, updates, etc done in Access are done to the local Access version first before being sync'd up in SharePoint via SharePoint Web Services.

What can be done is to take the nightly backup of the content databases and restore them into a completely different instance of SQL. You could then have another database there that uses linked tables to reference the related SharePoint tables from the database copies. You could then create views there that could be referenced from your workflow tool. This keeps the actual live SharePoint database in a supported state but provides the access you are looking for. This is an option but I doubt it will make your SQL team very happy.

This has two obvious drawbacks: 1) the data is always from the previous night and 2) the data is effectively read-only. If either of these is unacceptable for your purposes then you will need to look for a solution like John's or write your own via the Object Model.

OTHER TIPS

The short answer is you don't.

Directly interacting with a SharePoint content database will cause your SharePoint installation to lose Microsoft support.

This applies even to just using SELECT statements without changing any data.

Any interactions with SharePoint should be performed via the object model.

For SharePoint data, you don't access the underlying SQL data directly. Microsoft doesn't support doing this and you will be in an unsupported state.

To access SharePoint data you should use the object models provided by Microsoft. These include through C#/VB, Web Services, and JavaScript.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top