Accessing the CRM database directly RRS feed

  • Question

  • I have a situation where I have to access the CRM 2011 database directly through a SP to load some data.  Is accessing the CRM database directly a good idea, we tried to use LINQ and then Fetch XML but this does not cut it since the queries are too complicated.  Your thoughts on this please.
    Friday, June 24, 2011 2:17 AM

All replies

  • you can query CRM database, but remember to query FilteredView instead of table, but direct update is not supported in MS CRM, you have to use CRM SDK or CRM webservices

    refer http://msdn.microsoft.com/en-us/library/cc308184.aspx


    Mahain : My Dynamics CRM Blog
    Friday, June 24, 2011 4:14 AM
  • Firstly Microsoft do not recommend accessing the database directly and instead they recommend you use the SDK to do so.  The reason for this is because Microsoft could change the database tables and schema at any point in the future (although it's probably not likely), so you SP/database code could stop working.

    Also if you adding/deleting information then when you do it through the SDK it uses security roles and it also updates other information (lists and other entities perhaps).


    You say your queries are complex but if you access this information using the SDK then you could split this information into smaller chunks in some .NET code with smaller LINQ queries.


    I have seen code which has accessed the database directly and it worked but the worry you have is that if you upgrade your CRM version to a new rollup and especially if you upgrade to a new release your database code stop working.  Most of the time it probably work but it might stop.


    Friday, June 24, 2011 11:40 PM
  • It's not simply that this is unrecommended, it's that doing so will put your deployment in an unsupported state.  If you're comfortable with that risk, then tread lightly.  There are many tables that watch the information in CRM, and it's not always as simple as "creating a new record in a table".  On top of this are the solution layers that present, for all intents an purposes, overlays to base tables for extended information.  Use the Data Migration Manager, the Import feature, Scribe, or some other custom utility to interface with SOAP or REST to load new records.  Direct SQL injection is a dirty, corner-cutting solution that could produce undesirable results and leave you with no avenue to recover than a complete reinstallation.
    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.
    Friday, June 24, 2011 11:55 PM