SQL Server 2008 R2 - delete references - diagram

I have got the following problem: I created a database diagram in a database which is used by a special software. This software creates its own relationships programmatically - I only created the diagram to show the relationships to someone who is not familiar with the software.
I told the admin to delete the diagram, which he did, nonetheless there seem to be relationships from this diagram interfering with the software.
Do you have any idea how I can get rid of all the relationships?

Start SQL Server Management Studio (awesome tool). Use the tree view on the left, navigate to your database and subsequent to your tables. Check out, review and delete the relations if necessary.

Related

How do I get table names in intellisense under Visual Studio 2012 Database project?

We have recently moved our source control for stored procedure and function SQL files from VSS integrated with SSMS to a Database project under Visual Studio 2012. This has enabled us to easily integrate with TFS, which was our ultimate goal.
Under VSS with SSMS, we could see table names, function names, views, etc as we typed. But under Visual Studio 2012, we've noticed that Intellisense no longer knows these specific names. It does know database names and roles, so we know it is connected to the database at some level.
Is there an easy way to enable this functionality again? I've looked online, and I don't see many other people experiencing this issue/situation.
I found the solution, although it wasn't exactly what we were hoping for. We would like for VisualStudio to get the Schema information straight from the database. (The SQL files in our project were just for views and stored procedures). However, when we imported our table and functions into the project, it used that information to build the intellisense.
The good news is that we found a solution. The bad news is that when processes outside of our DB project alter some of the tables (we have a few that do this), then we have to remember to refresh those schemas in our project before intellisense will work properly.
Side note: here's a quick way to import your tables, functions, etc. especially when you have to do refreshes on said objects occasionally like we will have to do.
Before you get started, determine what kind of object you are going to be exporting from your database: Tables, Stored Procedures, Views or Functions. Create a folder under your DB project for each item that you want to export.
In SSMS, open the database server and right-click on the database instance you want to work with. Go down to Tasks -> Generate Scripts ... From there, select specific database objects. In this example, want to extract JUST the tables. Select "Tables", and leave all others unchecked, then click Next.
On this screen, select "single file per object", and give it a path to your "Tables" sub folder under your database project. I prefer to have my scripts DROP and CREATE instead of ALTER, so click "Advanced" and change create mode to "DROP and CREATE".
From here, just "Next" your way out of all of the dialogs. BOOM! You now have a series of SQL files that you can include in your project. These SQL files will enable intellisense to work properly, and you have a launchpad for generating all of your database objects without having to rebuild them all from scratch.

VS 2012 EF 5 using .net 4 and database first Layered applications concepts

I upgraded from VS2005 to VS2012 specifically to code in .Net 4,.Net 4.5, and use EF5. I am new to EF. I have Julie's EF book but it talks mainly about EF4 and POCO and it has me confused trying to implement EF5.
My hosting only allows me to run .Net 4 currently. I am trying to use EF5 on a new database.
I tried Code first to generate my database but I could not get it to generate the database. So I created the database first and then generated the model from the database with EF5. What I want is a layered website using ASP.NET Forms, Data Access Layer, and a Business Layer. The business layer I intend to build so I can use ObjectDataSource to pull in to the webpage along with some web services to use cascading dropdowns.
I have my NameX.edm model created but the tt files don't have the same names, they have Model1.tt and Model1.Context.tt is not the same name, why. Also Model1.Context.tt is empty. I am attempting to create the POCO classes running the EF5 DbContext but I am having trouble getting it to see the edm model. I read somewhere that EF5 creates the POCO automatically. I am not seeing the big picture here. Is my issue that I am not using .Net4.5?
What I have is a ASP.NET Application project, a EF Project, a POCO Project, and intend to have a forth project with the Business logic. How do I get the EF generated correctly and the POCO classes? I want a layered application for to scale well. Next question How to get the POCO classes to talk with the Business logic? My database is SQL. I am use to writing stored proceedures to accomplish everything through business logic.
If you are using Model First technique, make sure that you have references to System.Data.Entity and System.Data.Entity.Design. Also, you will need to create a reference to the EntityFramework.dll as well. It is located by default in c:\Program Files\Microsoft ADO.NET Entity Framework Feature CTP5\Binaries\EntityFramework.dll. If you can not find it, make sure you have installed the Entity Framework through your Package Manager Console. To do this, open up Tools, Library Package Manager, Package Manager Console, then type Install-Package EntityFrameWork.
Next you want to add a new item to your project. Right click on your solution, go to Add, then select New Item. You want to select Data from the Common Items section on the left, then select ADO.NET Entity Data Model.
Next Select Generate From Database. In the next screen, if you have not set up your connection to the server, click New Connection..., otherwise select your database from the drop down box. You need to select whether or not you want to include your connection string information in your config file. This is up to you how secure you need your application to be. If you choose not to, you need to pass this information as parameters in code. Also at the bottom, you will most likely want to change the auto-generated entities name to something easier for you to use. This name will be the name of your DBContext Class!
Next you want to select the tables you would like EF to create POCO's for. If you want all the tables just tick the tables items. Same goes for views and stored procs.
Once you click finish, then you should see all your fancy POCOS laid out in front of you in Design Mode. Note If you do not have primary keys in place for all your tables, I suggest you fix that! VS will spit at you if you do not have Primary Keys set, or if your naming conventions in your tables prevent VS from creating them for you implicitly.
This is a quick little tutorial on getting you up and running. You can now persist and pull data from your POCOS by using your DBContext object. For example if you named your DBContext class *Gary_Bettman_Sucks*, and you wanted to create a new record from your table called NHL you would do the following:
Dim context as New Gary_Bettman_Sucks
Dim PullMyGoalie as New NHL With {
.Goals = 0,
.Playoffs = False
}
context.Set(Of NHL).Add(PullMyGoalie)
context.SaveChanges()
I would Highly suggest you look into implementing the Repository Pattern with your design to encourage code re-use, and it will seriously make your life MUCH easier down the road.
Hope this helps!

SharePoint and DataBase Design

I don't know about SharePoint that much, so hope that someone can give me some good explanations for me.
For SharePoint application, we don't need to consider SharePoint DB design? Everything is done through List and SharePoint will take care of the Database? Don't need to consider it at all unless we are connecting to the external Database?
For Parent Child relationship, I have to use lookup field?
If we are developing using Web parts, we need to deploy it using Features. So eventually, there can be so many features in the production? Is it recommended in this way?
1)
For SharePoint application, we don't need to consider SharePoint DB
design ? Everything is done through List and SharePoint will take care
of the Database ? Don't need to consider it at all unless we are
connecting to the external Database ?
You do need to consider the database... In term of administration. back ups, restore, size and so on.
however you never directly read or write to it. You don't need to pay attention to the schema because you won't ever be directly using it. If you want to update something in SharePoint you do it pragmatically with c# / vb.net using the SharePoint API's. You have 2 API's one that works on the server called the SharePoint object model and one that works on a remote machine called the client side object model.
From a users perspective, you are correct lists contain data in SharePoint and are somewhat smiler to DB tables in some ways.
2)
For Parent Child relationship, I have to use lookup field ?
Yip
3)
If we are developing using Web parts, we need to deploy it using
Features. So eventually, there can be so many features in the
production ? Is it recommended in this way?
This can happen if you create a new solution for every web part but you can bundle multiple web parts in the same solution in the same project in the same feature
Right click on your project --> add new item. select a web part. By default the web parts will all be part of the same feature but you can separate them out and have multiple features in the same solution if you want to

How do I know which database is configured SharePoint?

I'm in a machine that has already SharePoint installed, so when I started the SharePoint Central Administration to config, this message appear to me: "Can not connect to the database configuration."
How do I know which database is configured SharePoint?
Normally the Admin database is created using the naming convention SharePoint_AdminContent_{GUID}. However if there's more than one, you'll need to use SQL Management studo or other tool to look inside the DBs, look for a table called "DatabaseInformation" which will contain two items, look in the AlternateAccessMappingXML entry and look for the XML tage IncomingUrl, that should help you narrow it down.
Or just use the SQL profiler and watch for connections.
By default SharePoint will install the Database on the same machine as the web server, but you can ask whoever installed SharePoint on the machine.
Anyhow, most likely it's not relevant and something else is the problem, follow the resolution methods described here and you'll probably have it fixed.

Easiest way to extract SharePoint list data to a separate SQL Server table?

Edited:
What is the easiest way to scrape extract SharePoint list data to a separate SQL Server table? One condition: you're in a work environment where you don't control the SQL Server behind the SharePoint Server, so you can't just pull from the UserData table.
Is there there any utilities that you can use to schedule a nightly extract?
Is Microsoft planning any improvement here for "SharePoint 4"?
Update Jan 06, 2009:
http://connectionstrings.com/sharepoint
For servers where office is not installed you will need:
this download
There is a SSIS SharePoint task you can use to grab the data info a regular dataflow:
http://www.codeplex.com/SQLSrvIntegrationSrv
Scraping? As in screen scraping? Are you serious? ;)
2 Options
SharePoint Object Model - http://msdn.microsoft.com/en-us/library/ms441339.aspx
SharePoint Web Services - http://msdn.microsoft.com/en-us/library/ms479390.aspx
specifically the Lists web service
The web services is how Excel/Access communicate with SharePoint to integrate with its lists.
In fact a bit of Google foo gives these two results :-
Connecting SQL Reporting Services to a SharePoint List
Accessing SharePoint List Items with SQL Server 2005 Reporting Services
The 2 minute answer is to use Data Synchronisation Studio from Simego ( http://www.simego.com ) just point it at your List and database and it will sync all the changes.
There is an ADO.NET adapter for MOSS 2007/2010 and WSS 3.0/4.0 available which goes under the name Camelot .NET Connector for Microsoft SharePoint. It enables you to query lists in SharePoint through standard SQL language, using SharePoint as a data layer.
Besides from the connector, there will be a large number of open source tools and utilities available, such as webparts for exporting data to various formats (XML, MySQL, ..), Joomla plugins, synchronization services, etc.
See http://www.bendsoft.com for more details and to watch webcasts. BendSoft is currently looking for beta-testers and encourage all feedback from the community.
Example:
SELECT * FROM My Custom SharePoint List
INSERT INTO Calendar (EventDate,EndDate,Title,Location) VALUES ('2010-11-04 08:00:00','2010-11-04 10:00:00','Morning meeting with Leia','Starbucks')
DELETE FROM Corp Images WHERE Image Name = 'marketing.jpg'
I had written a full article about this with step by step screenshot procedures. It does not use any third party components only SQL BI Tools and Sharepoint. Have a look here
http://macaalay.com/2013/11/01/how-to-archive-sharepoint-list-items-to-sql-server/
As Ryan said I would also suggest using object model / web services to store data to separate SQL database. I think that the best approach is to write an event handler that will trigger on your least and copy the data user inserted/updated.
Regarding your query about "SharePoint 4", Bill Gates made some remarks at SharePoint Conference 2008. He suggests enriching SQL tables with SharePoint data, and goes on to mention several other potentially cool things. What exactly he means and whether it will help solve your problem in the future is hard to say until we start seeing betas of WSS4 / MOSS 14.
I would go with the simego software, but i dont have the money, maybe a 15 days trial is enough!
If you have MOSS installed, the Business Data Catalog can be setup from the Sharepoint Central Administration to automagically synchronize data for you. This is a very powerful product and is included with MOSS. I love it when a client has it enabled so I can take advantage of it.
But some don't and for myself, I've found that if they don't have BDC running and available, inevitably they don't give developers many rights to SQL Server so SSIS is generally out of the question (but maybe that's just me). No problem; for those I'll pull together a lightweight EXE that runs on a scheduled task that queries Lists.asmx and pushes changes to a SQL Server table. Fairly trivial stuff for a simple list where nothing is deleted. Get yourself Visual Studio 2008, CAML Builder, and prepare for a good time. The Lists.asmx results is a little funny in that a list's row's fields are each a single node with a lot of attributes, with no child nodes ... something like this off the top of my head ... just remember that when coding ...
<z:row ows_Id="1" ows_Field1="A1" ows_Field2="B1"/>
<z:row ows_Id="1" ows_Field1="A2" ows_Field2="B2"/>
Complications in code occur with copying lists where items are deleted, or where there is a parent/child relationship between SP lists. You'd think I'd have some code to send you, but I haven't bothered putting together something I could reuse.
I'm sure there's other ways of handling it, but the scheduled task EXE so far has been reliable for me for multiple apps for multiple years.
i wrote some code to achieve it, you can find it over here
extract data from moss 2007
Depending on the exact nature of the data you need to insert, it may be possible to just use the auto generated RSS feed to get the information you want, a process will need to read the rss and formulate a query.
Otherwise a consoleapp/service could use the object model to do the same thing, but with more control over field information.
I wish something like this was much easier to do. Something that didn't need SSIS and was boiled down to a console tool that reads a xml config file for source/target/map info.
http://blogs.officezealot.com/mtblog/archive/2008/06/03/importing-list-data-into-sql.aspx

Resources