51
votes

I am more an end-user of SQL Server 2012. When I right click on a table name and select "Edit top 200 rows" menu item. I get this message:

 Exception has been thrown by the target of an invocation. (mscorlib)
 Additional information:
   Attempted to read or write protected memory. This is often an indication that 
   other memory is corrupt. (Microsoft.VisualStudio.OLE.Interop)

If I try to do the right click again, SQL server will stop working and close. I still can use SQL commands to insert or update database. I have been searching around for a solution, and found this link: http://social.msdn.microsoft.com/Forums/vstudio/en-US/42b79da5-6f1e-4122-a2cb-00def87a1ae2/microsoftvisualstudiooleinterop-attempted-to-read-or-write-protected-memory-this-is-often-an?forum=visualstudiogeneral

But it still does not help me to understand clearly the cause or find the solution to the issue. Any help to resolve this problem is highly appreciated. Thanks.

4
@alroc If the feature is there, it should be usable. In my case, it has been perfectly usable and stable for 3 years and all of a sudden doesn't work anymore. "It's buggy, don't use it" is completely unacceptable. - Dan Bechard
I've heard the advice of "don't use the table designer, it's buggy" for at least the past 5 years. Just because it works for you, most of the time doesn't mean that it's not buggy. People have reported issues to Microsoft, but it's still not as reliable as using actual SQL to update your tables. - alroc

4 Answers

92
votes

Are you attempting to edit a SQL 2014 database with the 2012 version (or earlier) of SQL Management Studio?

You can determine the SQL version of your database by running this query against your master database:

SELECT @@VERSION

I had the same problem and I was able to direct edit tables ('Edit Top 200') by installing and using SQL Server Management Studio 2014. Even if both your DB and Management Studio are version 2012, it might not hurt to upgrade Management Studio.

6
votes

I have also faced the same issue. And I noticed one thing that if you are using SQL database newer then the SQL management studio version, You will received that message. To overcome this issue just install SQL management studio equal or greater then version of database. i.e if you have SQL 2012 then you need to install SQL management studio 2012 or 2014.

0
votes

If anyone experiences the same issue in MS SQL SERVER from a different scenario ( eg - creating new database diagram )

And if this happened after fully uninstalling MS VISUAL STUDIO

Follow the Steps Below;

  1. Delete Folders MSDesigners8 and Visual Database Tools from the paths below.
  • C:\Program Files (x86)\Common Files\Microsoft Shared\MSDesigners8

  • C:\Program Files (x86)\Common Files\Microsoft Shared\Visual Database Tools

  1. Reinstall Visual Studio and Run Repair Tools from the Visual Studio Installer.

This Will Regenerate the folders we removed above and will repair partial fragments.

Now your SQL SERVER Database Diagrams should be working fine. Cheers :)

-1
votes

I have found a solution which does not require restart. Go to:

C:\Users\<User Name>\AppData\Local\Temp 

and delete all the files. Before deleting, close the SSMS window.