A query in SQL Server Management studio could fail with Error: "An error occurred while executing batch. Error message is: The file exists

A query in SQL Server Management studio could fail with Error: "An error occurred while executing batch. Error message is: The file exists

  • Comments 2

Below is one of the scenarios, I recently witnessed where a query was failing when executed from SSMS (SQL 2008) on windows client machine. There is no local SQL installation on the machine and had registered a remote SQL Server instance. When tried to run any query, we encountered below mentioned error message :
"An error occurred while executing batch. Error message is: The file exists."
In case you come across such situation, you might get the same error message even if you are clicking on any database and trying to expand its property.
You may think at this point that there could be some corruption with some dll files and that reinstalling the Shared components will resolve the issue. However, if you try to uninstall the shared component using :

·         Add/Remove Programs or

·         %program files%\Microsoft SQL server\100\setup bootstrap\release\x64\setuparp.exe ( for 32 bit, it will be under x32) to uninstall the components, the un-installation may fail with the below mentioned error message on the GUI window :

Message: One or more command-line switches were invalid.
If we drill down and look for the detail message we will see the below message :

2010-05-05 15:33:43 Slp: Installing WMI Provider
2010-05-05 15:33:43 Slp: Sco: Attempting to create base registry key HKEY_LOCAL_MACHINE, machine
2010-05-05 15:33:43 Slp: Sco: Attempting to open registry subkey SOFTWARE\Microsoft\Microsoft SQL Server\100
2010-05-05 15:33:43 Slp: Sco: Attempting to get registry value SharedCode
2010-05-05 15:33:43 Slp: SharedDirPath is C:\Program Files\Microsoft SQL Server\100\Shared\
2010-05-05 15:33:43 Slp: Attempting to install MOF/MFL file for WMI Provider C:\Program Files\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof
2010-05-05 15:33:43 Slp: Sco: Attempting to install MOF file
2010-05-05 15:33:43 Slp: Running: C:\Windows\system32\WBEM\mofcomp.exe "C:\Program Files\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof"
2010-05-05 15:33:43 Slp: Microsoft (R) MOF Compiler Version 6.1.7600.16385
2010-05-05 15:33:43 Slp: Copyright (c) Microsoft Corp. 1997-2006. All rights reserved.
2010-05-05 15:33:43 Slp: Parsing MOF file: C:\Program Files\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof
2010-05-05 15:33:47 Slp: C:\Program Files\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof (1): error SYNTAX 0X8004402f: Error creating temporary file
2010-05-05 15:33:47 Slp:
2010-05-05 15:33:47 Slp: Compiler returned error 0x8004402f
2010-05-05 15:33:47 Slp: Sco: Compile operation for mof file C:\Program Files\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof failed. Exit code 2
2010-05-05 15:33:47 Slp: Configuration action failed for feature CommonFiles during timing ConfigNonRC and scenario ConfigNonRC.
2010-05-05 15:33:47 Slp: One or more command-line switches were invalid.
2010-05-05 15:33:47 Slp: Configuration action failed for feature CommonFiles during timing ConfigNonRC and scenario ConfigNonRC.
2010-05-05 15:33:47 Slp: Microsoft.SqlServer.Configuration.Sco.ScoException: One or more command-line switches were invalid.
2010-05-05 15:33:47 Slp:    at Microsoft.SqlServer.Configuration.Sco.WmiProvider.InstallMof()
2010-05-05 15:33:47 Slp:    at Microsoft.SqlServer.Configuration.Slp.SlpConfigurationPrivate.Install_ConfigWMIProvider(Dictionary`2 actionData)
2010-05-05 15:33:47 Slp:    at Microsoft.SqlServer.Configuration.Slp.SlpConfigurationPrivate.Install_PostMSI(Dictionary`2 actionData, PublicConfigurationBase spcb)
2010-05-05 15:33:47 Slp:    at Microsoft.SqlServer.Configuration.Slp.SlpConfigurationPrivate.InstallImpl(ConfigActionTiming timing, Dictionary`2 actionData, PublicConfigurationBase spcb)
2010-05-05 15:33:47 Slp:    at Microsoft.SqlServer.Configuration.Slp.SlpConfigurationPrivate.Repair(ConfigActionTiming timing, Dictionary`2 actionData, PublicConfigurationBase spcb)
2010-05-05 15:33:47 Slp:    at Microsoft.SqlServer.Configuration.SqlConfigBase.PrivateConfigurationBase.Execute(ConfigActionScenario scenario, ConfigActionTiming timing, Dictionary`2 actionData, PublicConfigurationBase spcbCurrent)
2010-05-05 15:33:47 Slp:    at Microsoft.SqlServer.Configuration.SqlConfigBase.SlpConfigAction.ExecuteAction(String actionId)
2010-05-05 15:33:47 Slp:    at Microsoft.SqlServer.Configuration.SqlConfigBase.SlpConfigAction.Execute(String actionId, TextWriter errorStream)
2010-05-05 15:33:47 Slp: Exception: Microsoft.SqlServer.Configuration.Sco.ScoException.
2010-05-05 15:33:47 Slp: Source: Microsoft.SqlServer.Configuration.Sco.
2010-05-05 15:33:47 Slp: Message: One or more command-line switches were invalid..
2010-05-05 15:33:47 Slp: Watson Bucket 1 
 Original Parameter Values

The error message is self explanatory and says that  we are failing to create temporary files. This can occur if WMI is unable to access the TEMP and/or TMP location, either because of permissions or because the path is invalid.
We checked the environment variable and changed it to "C:\Windows\Temp".
Ran the un-installation and this time it went on fine.
Reinstalled the client component and we were now able to get the output of the results. However later when we were trying to register a new server it was failing with the below mentioned error message. 

“Unhandled exception has occurred in a component in your application. If you click Continue, the application will ignore this error and attempt to continue.” Key not valid for use in specified state.

 

Followed the below 2 step :

1. Close SSMS;

2. Go to the folder %appdata%\Microsoft\Microsoft SQL Server\100\Tools\ and check if there is a Shell folder, if so, rename it to Shell_Old;

 

 Each time SSMS starts it creates this folder and will  use old files. Hence by renaming the folder we are re-creating all the required components.

 

 

Regards,

Gaurav Srivastava

SE, SQL support

 

Reviewed by:

Nickson Dicson & Saket Suman

TL, SQL support

 

Leave a Comment
  • Please add 8 and 2 and type the answer here:
  • Post
  • See the end of this message for details on invoking

    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************

    Microsoft.SqlServer.Management.RegisteredServers.RegisteredServerException: Unable to read the list of previously registered servers on this system. Re-register your servers in the 'Registered Servers' window. ---> Microsoft.SqlServer.Management.Sdk.Sfc.SfcSerializationException: Serialization output is invalid. ---> System.Xml.XmlException: 'None' is an invalid XmlNodeType. Line 7, position 9.

      at System.Xml.XmlReader.ReadStartElement()

      at Microsoft.SqlServer.Management.Sdk.Sfc.SfcSerializer.Deserialize(XmlReader xmlReader, SfcObjectState state)

      --- End of inner exception stack trace ---

      at Microsoft.SqlServer.Management.Sdk.Sfc.SfcSerializer.Deserialize(XmlReader xmlReader, SfcObjectState state)

      at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServersStore.InitChildObjects(String file)

      --- End of inner exception stack trace ---

      at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServersStore.InitChildObjects(String file)

      at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServersStore.InitializeLocalRegisteredServersStore()

      at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServersStore.get_LocalFileStore()

      at Microsoft.SqlServer.Management.UI.ConnectionDlg.ConnectionDialog.OnLoad(EventArgs e)

      at System.Windows.Forms.Form.OnCreateControl()

      at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

      at System.Windows.Forms.Control.CreateControl()

      at System.Windows.Forms.Control.WmShowWindow(Message& m)

      at System.Windows.Forms.Control.WndProc(Message& m)

      at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

      at System.Windows.Forms.ContainerControl.WndProc(Message& m)

      at System.Windows.Forms.Form.WmShowWindow(Message& m)

      at System.Windows.Forms.Form.WndProc(Message& m)

      at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

      at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

      at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ************** Loaded Assemblies **************

    mscorlib

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.3615 (GDR.050727-3600)

       CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

    ----------------------------------------

    AppIDPackage

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1015 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/AppIDPackage.DLL

    ----------------------------------------

    System

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll

    ----------------------------------------

    Microsoft.SqlServer.SqlTools.VSIntegration

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.1600.22 ((SQL_PreRelease).080709-1414 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.SqlTools.VSIntegration.DLL

    ----------------------------------------

    Microsoft.VisualStudio.Shell.Interop

       Assembly Version: 7.1.40304.0

       Win32 Version: 7.10.6071

       CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.Shell.Interop/7.1.40304.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Shell.Interop.dll

    ----------------------------------------

    Microsoft.VisualStudio.OLE.Interop

       Assembly Version: 7.1.40304.0

       Win32 Version: 7.10.6070

       CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.OLE.Interop/7.1.40304.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.OLE.Interop.dll

    ----------------------------------------

    System.Windows.Forms

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

    ----------------------------------------

    System.Drawing

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

    ----------------------------------------

    SqlWorkbench.Interfaces

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1015 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/SqlWorkbench.Interfaces.DLL

    ----------------------------------------

    Microsoft.SqlServer.SqlTDiagM

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.1600.22 ((SQL_PreRelease).080709-1414 )

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.SqlTDiagM/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.SqlTDiagM.dll

    ----------------------------------------

    Microsoft.SqlServer.Instapi

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.1600.22 ((SQL_PreRelease).080709-1414 )

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Instapi/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Instapi.dll

    ----------------------------------------

    Microsoft.VisualStudio.Shell

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.1826 (QFE.050727-1800)

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Shell/2.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Shell.dll

    ----------------------------------------

    Microsoft.VisualStudio.Shell.Interop.8.0

       Assembly Version: 8.0.0.0

       Win32 Version: 8.0.50727.1826 (QFE.050727-1800)

       CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.Shell.Interop.8.0/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Shell.Interop.8.0.dll

    ----------------------------------------

    Microsoft.SqlServer.Management.SDK.SqlStudio

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.1600.22 ((SQL_PreRelease).080709-1414 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.SDK.SqlStudio.DLL

    ----------------------------------------

    Microsoft.SqlServer.Management.Sdk.Sfc

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1045 )

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Management.Sdk.Sfc/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Management.Sdk.Sfc.dll

    ----------------------------------------

    Microsoft.SqlServer.Management.Reports

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1015 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.Reports.DLL

    ----------------------------------------

    ObjectExplorer

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1015 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/ObjectExplorer.DLL

    ----------------------------------------

    SqlMgmt

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1015 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/SqlMgmt.DLL

    ----------------------------------------

    Microsoft.VisualStudio

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.1826 built by: QFE

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio/2.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.dll

    ----------------------------------------

    System.Drawing.Design

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing.Design/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.Design.dll

    ----------------------------------------

    Microsoft.VisualStudio.Designer.Interfaces

       Assembly Version: 1.0.5000.0

       Win32 Version: 1.1.4322.573

       CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.Designer.Interfaces/1.0.5000.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Designer.Interfaces.dll

    ----------------------------------------

    ConnectionDlg

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1015 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/ConnectionDlg.DLL

    ----------------------------------------

    Microsoft.SqlServer.Management.Controls

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1015 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.Controls.DLL

    ----------------------------------------

    Microsoft.SqlServer.Management.UserSettings

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.1600.22 ((SQL_PreRelease).080709-1414 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.UserSettings.DLL

    ----------------------------------------

    Accessibility

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll

    ----------------------------------------

    Microsoft.SqlServer.RegSvrEnum

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.1600.22 ((SQL_PreRelease).080709-1414 )

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.RegSvrEnum/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.RegSvrEnum.dll

    ----------------------------------------

    Microsoft.SqlServer.Management.SqlStudio.Explorer

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1015 )

       CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.SqlStudio.Explorer.DLL

    ----------------------------------------

    System.Design

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Design/2.0.0.0__b03f5f7f11d50a3a/System.Design.dll

    ----------------------------------------

    System.Data

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)

       CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll

    ----------------------------------------

    Microsoft.NetEnterpriseServers.ExceptionMessageBox

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1045 )

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.NetEnterpriseServers.ExceptionMessageBox/10.0.0.0__89845dcd8080cc91/Microsoft.NetEnterpriseServers.ExceptionMessageBox.dll

    ----------------------------------------

    Microsoft.SqlServer.ConnectionInfo

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1045 )

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.ConnectionInfo/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.ConnectionInfo.dll

    ----------------------------------------

    Microsoft.SqlServer.Management.RegisteredServers

       Assembly Version: 10.0.0.0

       Win32 Version: 10.0.2531.0 ((Katmai_PCU_Main).090329-1045 )

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Management.RegisteredServers/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Management.RegisteredServers.dll

    ----------------------------------------

    System.Xml

       Assembly Version: 2.0.0.0

       Win32 Version: 2.0.50727.3074 (QFE.050727-3000)

       CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll

    ----------------------------------------

    ************** JIT Debugging **************

    To enable just-in-time (JIT) debugging, the .config file for this

    application or computer (machine.config) must have the

    jitDebugging value set in the system.windows.forms section.

    The application must also be compiled with debugging

    enabled.

    For example:

    <configuration>

       <system.windows.forms jitDebugging="true" />

    </configuration>

    When JIT debugging is enabled, any unhandled exception

    will be sent to the JIT debugger registered on the computer

    rather than be handled by this dialog box.

  • Hi,

    I followed these steps, but still I'm getting the same error.

    1. Close SSMS;

    2. Go to the folder %appdata%\Microsoft\Microsoft SQL Server\100\Tools\ and check if there is a Shell folder, if so, rename it to Shell_Old;

    Could you please provide me some more information.

    Thank you.

Page 1 of 1 (2 items)