Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to know if it is a correct thing to access SharePoint content database in code i.e (using custom SQL queries)? If not can anyone provide me with an explanation why shouldn't it be done?

share|improve this question

1 Answer 1

  1. Directly querying or modifying the database can place extra load on a server, or can expose information to users in a way that violates security policies or personal information management policies.
  2. If server-side code must query data, then the process for acquiring that data should be through the built-in SharePoint object model, and not by using any type of query to the database.
  3. Client-side code that must modify or query data in SharePoint Products and Technologies can do this by using calls to the built-in SharePoint Web services that in turn call the object model.
  4. Direct modification of the SharePoint database or its data is not recommended because it puts the environment in an unsupported state.
  5. If a server component requires information from the database, it must get that data by using the appropriate items in the SharePoint object model, and not by trying to get the items from the data structures in the database through some query mechanism.
  6. Your custom queries might lead to incorrect data being retrieved.
  7. Direct SELECT statements against the database take shared read locks at the default transaction level so your custom queries might cause deadlocks and hence stability issues.
  8. Your queries are not guaranteed to work after applying any patches or service packs to SharePoint since Microsoft could change the database schema anytime.

Link to msdn

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.