Business Connectivity Services for a large scale database having several stored procedures - sharepoint-2010

I am working on a project having a large scale database with several stored procedures and I need to use the data in SharePoint 2013, the database is in SQL Server 2008 R2
According to my understanding I have two options:
1) is to create a Web service, using entity framework to interact with the database and most probably will use WebAPI. My logic will be in Stored procedures or DAL layer.
2) Secondly, I did a little research and got to know about the Business connectivity services provided by the SharePoint 2010/2013 as I am working with 2013 so I will be using visual studio 2012. Now learning more about the BCS I understood that I can map each table as a content type and then somehow define relationship. Anwyay, implementing BCS is a separate issue which I think I will somehow manage.
My question is how am I going to import/include my stored procedures? and if not stored procedures then where will I write my queries to get the data from the BCS?
Please direct me to right direction. Thank you.

Using a custom BCS connector you implement the way you want to retrieve the data from the DB (directly in C#), so you can query directly the table, or stored procedures.
If you want to try a BCS connector to create an external content type to use in SharePoint, take a look at my blog. My example is related to indexing sql data for the search, but the way it's done in SharePoint is creating an external content type, and this content type is the one that you index. So you'll find useful information on how to create that BCS connector.

Related

webparts SQL server tables

My new project requires me to create some 12 SQL tables and build some web parts in SharePoint 2010, to perform CRUD operation on the tables. One main table has around 25 columns and the rest of the tables has 2 or 3 columns and some are just join tables.
The main requirement is the when someone adds or changes the data in the tables it should not be available to everyone. A manager must approve the data before it is updated in the table.
I don’t have much experience in SQL or SharePoint for that matter, so can someone let me know how this can be done.
And is web parts the best way to do the CRUD operations, or can I use BCS which I feel is easy?
I would look at Access Web App. In SharePoint 2010 it will create lists as underlying data "tables", you can create workflows on these lists.
If you have limited experience in SQL or SharePoint this will offer you a GUI driven solution with very little or no coding requirements.
Access Web Apps offer a more versatile BCS-type solution. It is more bulky, but it is far easier to develop your solution and you can still leverage your SharePoint permissions and workflows.

SQL Server trigger to update Sharepoint List

So, it looks like I'm gonna have to replicate a couple of reference tables from my SS2k5 db on SP2k7 in order to do dropdown boxes on my document library. Small tables, maybe a hundred entries, and not often updated. Ths SP Server is not the SS server.
I know how to build triggers, but how do I reference the SP table to update it from the SS trigger, and what are the authentication issues?
Anybody do this before?
I know there is a thing called Business Catalog Data or something like that, but I don't have full privs on this SP site, so I'm likely not to be able to get to that, and I've never used it before, hence the trigger idea.
Does it really need to be real time via a trigger? Or can it be delayed and processed via an ETL job? If the latter is acceptable, I recommend taking a look at Extracting and Loading SharePoint Data in SQL Server Integration Services. I have used this adapter on past projects to transfer data between SQL Server and SharePoint.
P.S. I would not recommend writing directly to the SharePoint content database. Making changes directly to a content database is not supported and is not considered a best practice.

What is the best way to create an enhanced Data Dictionary?

Without going into specifics...I have a large SQL Server 2005 database with umpteen stored-procedures.
I have multiple applications from WinForm apps to WebServices all of which use this DB.
My simple objective now is to create a meta-database...a prospective data-dictionary where I can maintain details of which specific app. file uses which SP.
For example, My application Alpha which has a file Beta.aspx...uses 3 SPs which are physically configured for usage in BetaDAL.cs
You might have inferred by now,it will make life easier for me later when there is a migration or deprecation....where I can just query this DB SP-wise to get all Apps/Files that use the DB or vice-versa.
I can establish this as a single de-normalized table..or structure it in a better way.
Does some schema already exist for this purpose?
SQL Server supports what are called extended properties, basically a key-value dictionary attached to every object in the catalog. You can add whatever custom information about the catalog (comments on tables, columns, stored procedures, ...) you wish to store as extended properties and query them along with the normal catalog views.
Here's one overview (written for SQL Server 2005, but roughly the same techniques should apply for 2000 or 2008).

Using Database entries to dynamically create a visio diagram

Is this possible?
We have a Configuration Management Database that stores information such as our servers, what datacentre they're stored in, applications that reside on them, as well as interfaces that send data from one application to another.
We would like to use Visio to connect to our SQL 2005 database, and automatically generate a flow diagram that details these dependancies and relationships.
So again - is this possible? If so, does anyone know of some documentation that details how to do this?
Is this what you are looking out for?

How can I synchronize views and stored procedures between SQL Server databases?

I have a 'reference' SQL Server 2005 database that is used as our global standard. We're all set up for keeping general table schema and data properly synchronized, but don't yet have a good solution for other objects like views, stored procedures, and user-defined functions.
I'm aware of products like Redgate's SQL Compare, but we don't really want to rely on (any further) 3rd-party tools right now.
Is there a way to ensure that a given stored procedure or view on the reference database, for example, is up to date on the target databases? Can this be scripted?
Edit for clarification: when I say 'scripted', I mean running a script that pushes out any changes to the target servers. Not running the same CREATE/ALTER script multiple times on multiple servers.
Any advice/experience on how to approach this would be much appreciated.
1) Keep all your views, triggers, functions, stored procedures, table schemas etc in Source Control and use that as the master.
2) Failing that, use your reference DB as the master and script out views and stored procedures etc: Right click DB, Tasks->Generate Scripts and choose your objects.
3) You could even use transactional replication between Reference and Target DBs.
I strongly believe the best way is to have everything scripted and placed in Source Control.
You can use the system tables to do this.
For example,
select * from sys.syscomments
The "text" column will give you all of the code for the store procedures (plus other data).
It is well worth looking at all the system tables and procedures. In fact, I suspect this is what RedGate's software and other tools do under the hood.
I have just myself begun experimenting with this, so I can't really be specific about all the gotcha's and what other system tables you need to query, but this should get you started.
Also see:
Query to list SQL Server stored procedures along with lines of code for each procedure
which is slightly different question than yours, but related.
I use (and love) the RedGate tools, but when Microsoft announced Visual Studio 2010, they decided to allow MSDN subscribers who get Visual Studio 2008 Team System to also get Visual Studio 2008 Database Edition (which has a schema compare tool).
So if you or your organization has an MSDN subscription, you might want to consider downloading and installing the Database Edition over your Team System to get all the features now.
More details at http://msdn.microsoft.com/en-us/vsts2008/products/cc990295.aspx
Take a look at ScriptDB on Codeplex (http://www.codeplex.com/ScriptDB)
It is a console C# app that creates scripts of the SQL Database objects using SMO. You can use that to compare scripts generated on two servers. Since its open source, adjust it if you need it.
Timur