Attempted to read or write protected memory-SQL - sql

I am trying to save a view in sql-server management studio which brings the following error message
Attempted to read or write protected memory. This is often an indication that other memory is corrupt
The same query works fine if I run it separately.
The full error message is below
===================================
Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (Microsoft.SqlServer.Management.DataTools.Interop)
------------------------------
Program Location:
at Microsoft.SqlServer.Management.DataTools.Interop.IDTDocTool.Save(Object dsRef, String path, Boolean okToOverwrite)
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ViewDesignerNode.Save(VSSAVEFLAGS dwSave, String strSilentSaveAsName, IVsUIShell pIVsUIShell, IntPtr punkDocDataIntPtr, String& strMkDocumentNew, Int32& pfCanceled)
I am not sure where to look at

I got the same error message a few days back working on some reports on BIDS and strangely enough just resetting the windows layout fixed the issue. Because I had Solution Explorer sitting on a separate monitor.
While I was looking for a solution for this problem online I came across cases where people were getting this error message because of the other software installed on their machine.
There is no One reason for this error but hopefully this is a good place to start from. resetting the windows layout can you believe this :)
Question I asked a few weeks ago and didnt get any answers see here

I also faced same error message while trying to edit top rows. But manual query works fine.
Reason behind:
I already installed SQL Server Management 2012.
Then i installed SQL Server Management 2018.
I opened SSMS from 2012 where we faced the above mentioned issue.
Later opened SSMS 2018, then problem got rectified.

Related

SQL "an error occurred during local report processing"

Apologies first of all if there is an answer to this elsewhere on the site. I've checked some of the proposed solutions and can't find anything appropriate.
So I've got this SSRS report that works fine when deployed but won't run locally during testing. The main query itself works when run in the query editor, as do all the sub queries that provide data for parameter drop lists but when I try to preview it, I get the error.
Bear in mind it used to work, up until the end of last year, which was when it was last updated.
I've tried removing all the tables and matrices on a copy (replacing with one very simple table), the parameters went too and I still get the error. I've also downloaded the server version, renamed it and redeployed it, works online, but not locally. As the error message is brutally vague, I've run out of ideas of things to try. Apart from switching over to PowerBI, can anyone think of anything else I could do to understand where the error is from?
Possibly relevant - the main query has some recursion in a subquery, but only a couple of levels. Could this be related? As I've said before, it used to work...
PS I'm using VS 16.7.2 from server V13.0.4466.4
PPS I also added the query to a brand new report and it errored so I think it must be something related to the SQL itself?

Recent rash of Microsoft Access database files in an inconsistent state

A large number of our clients operating a split front end/back end Microsoft Access application we built are encountering frequent but intermittent database file corruption issues. When the back end file is opened this message appears: "Microsoft Access has detected that this database is in an inconsistent state, and will attempt to recover the database … "
Opening the database with DAO using Visual Basic code results in error code 3343, "Unrecognized database format."
The repair attempt succeeds and we have not witnessed any data loss or dropping of primary keys, indexes, or relationships. Most cases involve where the back end file is located on a shared network drive. Some searches suggest that the latest Windows 10 update 1803 is suspect. Has anybody else encountered this?
It has recently been reported several times. A very thorough coverage of this issue can be found here.
Strangely, the cure can - at least for some cases - be found in old support threads:
Moved to Server 2012 getting Access Database Corruption
Cannot access shared files or folders on a drive in Windows Server 2012 or Windows Server 2012 R2
Comments:
It’s a bit strange though as the patch to fix the issue is back in May
2014 which is already installed on the server.
I can only think that
something in the latest Windows 10 Build 1803 has brought up the issue
again as it was PC’s that are running that build were causing the
problem.
The fix is adding the following entry into Vospers Server
2012 R2 registry:
Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters
Value: DisableLeasing
Type: DWORD
Data: 0x1
We testing this on our server and the problem went away. As soon as we
changed the ‘Disable leasing’ value to ‘0’ again, the problem
returned.
I can’t find a reasonable explanation yet as to why this
has started to happen last week but if it works and doesn’t cause any
further issues elsewhere then I’m ok with that.
Also note that homegroups have been removed from Win10 1803. This may affect rights on shared folders.

Data source name not found and no default driver specified

This error is occurring on every *.asp page in the application, but the *.aspx pages work just fine.
I did not develop the application, but the person who did has long since left the company. We have about 20 customers, all with the program working just fine. One of the customers had their server crash, and we had to re-set it up on their new server. Everything is working just fine now, except for this error on the *.asp pages.
The same connection string is used for all of our customers, so I know the problem is not there. There are no system DSNs or user DSNs defined on any of our customers.
This is a 32-bit application on a 32-bit server (server 2003 with SQL 2005).
I'm pretty sure it's a permissions or setting error, but I have checked absolutely everything I can think of.
Please help.
A company with 1400 employees can't use this program until I get it back up and running. I have no idea what else to do.
Thanks everyone for your help.
Sorry it took me a little bit to respond to you, but I had heard back from the original developer, and he had a hidden connection string deep within the program specifically to trip someone up if they were trying to install the program without authorization. He gave me the info I needed and it worked beautifully.
Thanks again!

SSMS 2012 hanging when opening multiple query windows or files

I recently upgraded from 2005 to 2012 (about 10 months). When I first started using SSMS2012 it worked great was able to open multiple windows in a particular database. For about that last 2-3 months SSMS hangs when I try to open more than 1 query window or open a file. It is random but happens a majority of the time. I have been able to interrupt the hang a few times. When I interrupt it I get the login screen and it sits there trying to log in apparently unsuccessfully. If I cancel the login and try it again with the same entries it connects just fine and things are great, but I have to do this for every window and I cannot often break into that screen before it stops responding.
I have searched extensively and have not found an answer to this problem. It only appears to be happening to a particular instance. The instance does not show any signs of issues, has been rebooted and configuration checked for inconsistencies, etc. I am at a loss. If anyone has experienced this and has been able to resolve it I would appreciate a response.
Again this is a fresh install of 2012 standard with 2005 imported databases. All indications show that it is working fine. compatibility level for a majority of the databases are still 90, until I can clear them for 11 with the software they house. I have a test environment with the restored versions on a different server and no issues result from that instance - I can open up multiples without incident. My belief is it is something with that particular instance, but I am not sure where else to look.
Thank you in advance.

SSMS 2012 System.OutOfMemoryException (client side) and SQL Prompt (debug info incl)

Some background: I've been encountering this memory exception within SSMS 2012 since it was released coupled with Red Gate's SQLPrompt (this exception never happens in my SSMS 2008R2 on the same laptop).
I was originally encountering these exceptions daily (SSMS2012 and SQLPrompt) which forces me to close and reopen SSMS (along with everything I was working on). Months ago I stumbled upon a support thread that pointed possible add-on's as being the cause so I uninstalled my only add-on (SQL Prompt, but did not uninstall the rest of the developer's bundle) and went many months without a single exception much less the System.OutOfMemoryException exception.
Once SP1 was released for 2012 I applied it and reinstalled SQL Prompt again (the latest version) to see if maybe the issue had been addressed and within 7 hours of development time I was greeted again with the infamous System.OutOfMemoryException.
Through out all of this I've been opening tickets with Red Gate and submitting debug logs where they see the exception but since the memory exception doesn't explicitly list SQLPrompt they won't escalate the issue to the development team. Prior to this specific exception SQL Prompt however is throwing numerous exceptions (some listed below) within the SSMS 2012 IDE (Visual Studio 2010). I believe that the memory exception is symptomatic of an issue with how SQL Prompt manages cached data and eats up the available memory for SSMS which eventually throws an exception as a result.
I've learn how to defer this issue and how to reproduce it and it is directly related to two variables:
Connecting and working on multiple instances in SSMS (Object Explorer and Query windows). I.e. Connected to 7 instances netted the exception within 2-3 hours.
Returning result sets from multiple instances. This includes queries used by SSMS to return information to the IDE and results returned to the individual query windows.
The more instances I'm connected to the fast the exception is raised which leads me SQL Prompt's caching all of the object information per instances. Once the memory exception is raised the situation degrades until SSMS crashes completely (unless I close it first).
What I am after is how to collect more/better information to submit to Red Gate to correct this issue. This is where I need your help.
Laptop: HP Elite book 8440
RAM: 6GB
Current OS:
Win 7 Enterprise Ed Sp1
Here are some of exceptions caused by SQL Prompt:
System.ArgumentOutOfRangeException "Specified argument was out of the range of valid values."
Microsoft.VisualStudio.Text.Implementation.BinaryStringRebuilder.GetLineNumberFromPosition(N/A,N/A)
Microsoft.VisualStudio.Text.Implementation.TextSnapshot.GetLineFromPosition(Microsoft.VisualStudio.Text.Implementation.TextSnapshot,N/A)
Microsoft.VisualStudio.Editor.Implementation.VsTextBufferAdapter.GetLineIndexOfPosition(N/A,System.Int32,System.Int32&,System.Int32&)
RedGate.SQLPrompt.CommonVS.Editor.VSScriptProvider.PositionFromIndex(RedGate.SQLPrompt.CommonVS.Editor.VSScriptProvider,System.Int32)
RedGate.SqlPrompt.Metadata.Script.ScriptProviderBase.GetText(RedGate.SQLPrompt.CommonVS.Editor.VSScriptProvider,System.Int32,System.Int32)
RedGate.SqlPrompt.Engine.NewEngine.SqlPromptEngine.GetCandidates(RedGate.SqlPrompt.Engine.NewEngine.SqlPromptEngine,System.Int32)
RedGate.SqlPrompt.Engine.PromptEngineEmulator.get_GetSuggestions(RedGate.SqlPrompt.Engine.PromptEngineEmulator)
RedGate.SqlPrompt.Engine.AutoCompleter.m_FilterChanged(RedGate.SqlPrompt.Engine.AutoCompleter,RedGate.SqlPrompt.Engine.PromptEngineEmulator,System.EventArgs)
RedGate.SqlPrompt.Engine.PromptEngineEmulator.OnFilterChanged(RedGate.SqlPrompt.Engine.PromptEngineEmulator)
RedGate.SqlPrompt.Engine.PromptEngineEmulator.set_Index(RedGate.SqlPrompt.Engine.PromptEngineEmulator,System.Int32)
RedGate.SqlPrompt.Engine.PromptEngineEmulator.set_CaretPosition(RedGate.SqlPrompt.Engine.PromptEngineEmulator,N/A)
RedGate.SQLPrompt.CommonUI.Editor.EditorWindowBase.SetEngineCaretPosition(RedGate.SQLPrompt.SSMSUI.SSMSEditorWindow,N/A)
RedGate.SQLPrompt.CommonUI.Editor.EditorWindowBase.UpdateUIPrompts(RedGate.SQLPrompt.SSMSUI.SSMSEditorWindow)
RedGate.SQLPrompt.CommonVS.Editor.VSEditorWindow.OnTextViewCommandExec(RedGate.SQLPrompt.SSMSUI.SSMSEditorWindow,RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor,RedGate.SQLPrompt.CommonVS.Editor.CommandExecEventArgs)
RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor.AfterCommandExecute(RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor,RedGate.SQLPrompt.CommonVS.Editor.CommandExecEventArgs)
RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor..(RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor.)
RedGate.SQLPrompt.CommonUI.Utils.ErrorDialog.Do(System.Action)
RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor.(RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor,System.Guid&,System.Uint32,System.Uint32,System.IntPtr,System.IntPtr)
RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor..(RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor.,System.Guid&,System.Uint32,System.Uint32,System.IntPtr,System.IntPtr)
Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(N/A,N/A,N/A,N/A,N/A,N/A)
System.ArgumentException 00:05:14.7510000 "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
#mMc.#JQub.#OQub(#mMc.#JQub,N/A,System.Uint32,#mMc.#k3ub&)
#mMc.#JQub.#z26.#8Di(#mMc.#JQub.#z26)
RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(RedGate.SQLSourceControl.CommonUI.Forms.ErrorDialog,System.Action,System.Predicate`1<System.Exception>,System.Boolean)
RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(RedGate.SQLSourceControl.CommonUI.Forms.ErrorDialog,System.Action)
RedGate.SQLSourceControl.CommonUI.Forms.ErrorDialog.Do(System.Action)
And here is the Memory Exception:
System.OutOfMemoryException <null>
System.Text.StringBuilder.set_Capacity(System.Text.StringBuilder,N/A)
Microsoft.SqlServer.Management.QueryExecution.QEDiskStorageView.set_MaxNumBytesToDisplay(N/A,N/A)
Microsoft.SqlServer.Management.QueryExecution.QEDiskDataStorage.GetStorageView(N/A)
Microsoft.SqlServer.Management.QueryExecution.QEResultSet.StartRetrievingData(Microsoft.SqlServer.Management.QueryExecution.QEResultSet,System.Int32,N/A)
Microsoft.SqlServer.Management.QueryExecution.ResultSetAndGridContainer.StartRetrievingData(N/A,N/A,N/A)
Microsoft.SqlServer.Management.QueryExecution.ResultsToGridBatchConsumer.OnNewResultSet(Microsoft.SqlServer.Management.QueryExecution.ResultsToGridBatchConsumer,N/A,N/A)
Microsoft.SqlServer.Management.QueryExecution.QESQLBatch.ProcessResultSet(Microsoft.SqlServer.Management.QueryExecution.QESQLBatch,N/A)
Microsoft.SqlServer.Management.QueryExecution.QESQLBatch.DoBatchExecution(Microsoft.SqlServer.Management.QueryExecution.QESQLBatch,System.Data.SqlClient.SqlConnection,N/A)
Microsoft.SqlServer.Management.QueryExecution.QESQLBatch.Execute(N/A,N/A,N/A)
Microsoft.SqlServer.Management.QueryExecution.QEOLESQLExec.DoBatchExecution(Microsoft.SqlServer.Management.QueryExecution.QEOLESQLExec,Microsoft.SqlServer.Management.QueryExecution.QESQLBatch)
Microsoft.SqlServer.Management.QueryExecution.QESQLExec.ExecuteBatchCommon(Microsoft.SqlServer.Management.QueryExecution.QEOLESQLExec,N/A,N/A,System.Boolean&)
Microsoft.SqlServer.Management.QueryExecution.QEOLESQLExec.ExecuteBatchHelper(N/A,N/A,N/A,N/A)
Microsoft.SqlServer.Management.QueryExecution.QEOLESQLExec.ProcessBatch(N/A,N/A,N/A)
.BatchParser.ThunkCommandExecuter.ProcessBatch(N/A,N/A,N/A)
Again, to be clear, I don't know if the other exceptions are related or not but the memory exception only happens with SQL Prompt installed.
Thanks for your assistance!
At this point RedGate has finally admitted the issue is that the SQL Prompt plug-in is working in-process with the 32-bit SSMS client and eventually chokes the memory resulting in the out-of-memory exception.
Their response to a fix for this would be "maybe" in a year or so which, when you are paying for annual support, is a slap in the face. I've since refused to pay for further support for 2 existing Tool-belt licenses over this issue, an issue that I have fought with since 2012, until they correct this. If this is affecting you then, and if you can, do the same and vote with your wallet to motivate them to make this fix a higher priority.
If and when that day comes I will update this answer post with the version information of the corrected build of SQL Prompt that no longer operates within the 32-bit memory space of SSMS.exe.
What works for me is Disabling Code suggestions in SQL prompt, then I can run the same query and then get the results.
I can then Enable Code suggestions in SQL prompt and the error stays away for a while.
Can you try limiting the number of columns as described in this post and see if it helps?
http://redgate.uservoice.com/forums/94413-sql-prompt-feature-suggestions/suggestions/1364757-disable-sql-prompt-on-certain-databases