SQL Server - 执行批处理时出错。错误信息是:目录名无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/704914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:33:53  来源:igfitidea点击:

SQL Server - An error occurred while executing batch. Error message is: The directory name is invalid

sqlsql-server-2005

提问by lstanczyk

Our database server had run out of disk space, after freeing up some disk space any query run in sql server management studio, with the results sent to grid view, resulted in this error:
An error occurred while executing batch. Error message is: The directory name is invalid.

我们的数据库服务器磁盘空间不足,在释放一些磁盘空间后,在 sql server management studio 中运行的任何查询,并将结果发送到网格视图,导致此错误:
执行批处理时发生错误。错误信息是:目录名无效。

When the results sent to text view the queries worked fine.

当结果发送到文本视图时,查询工作正常。

Does anyone know why this error occurs and how to get rid of it?

有谁知道为什么会发生这个错误以及如何摆脱它?

回答by scott_lotus

Received the message:

收到消息:

SQL Server - An error occurred while executing batch. Error message is: The directory name is invalid

SQL Server - 执行批处理时出错。错误信息是:目录名无效

When trying to execute a query in Management Studio after deleting temp files from c:\documents and settings\administrator\local settings\temp

删除临时文件后尝试在 Management Studio 中执行查询时 c:\documents and settings\administrator\local settings\temp

Resolved when logging out of server session and back in again.

退出服务器会话并重新登录时解决。

This resolution fixes this error on the following environments:

此解决方案修复了以下环境中的此错误:

  • Windows Server 2003
  • Windows Server 2008
  • Windows Server 2012
  • Sql Server 2005
  • Sql Server 2008
  • Sql Server 2008 R2
  • Sql Server 2012
  • Sql Server 2014
  • Sql Server 2016
  • 视窗服务器 2003
  • 视窗服务器 2008
  • 视窗服务器 2012
  • 数据库服务器 2005
  • 数据库服务器 2008
  • Sql Server 2008 R2
  • 数据库服务器 2012
  • 数据库服务器 2014
  • 数据库服务器 2016

回答by lstanczyk

All you need to do is to open command prompt and type: mkdir %temp%and press Enter.

您需要做的就是打开命令提示符并键入: mkdir %temp%然后按 Enter。

Simple as that. No logout/login required.

就那么简单。无需注销/登录。

回答by Preeti Joshi

I had similar problem on SQL Server 2012. I checked the folder value in %TEMP% variable (echo %TEMP% from command prompt ) and noticed that the folder did not exist. I created the folder and it did the trick!

我在 SQL Server 2012 上遇到了类似的问题。我检查了 %TEMP% 变量中的文件夹值(从命令提示符回显 %TEMP% )并注意到该文件夹​​不存在。我创建了文件夹,它成功了!

回答by John

I had this issue on my webserver (windows server r2 running SQL Server 2012)

我的网络服务器上有这个问题(运行 SQL Server 2012 的 Windows Server r2)

The directory name is invalid.
(mscore lib)

Logging out (killing my remote session) and logging back in fixed the issue for me.

注销(终止我的远程会话)并重新登录为我解决了这个问题。

回答by SqlACID

Is the "Default Location for saving Query Results" set to a valid path in Tools/Options/Query Results/SQL Server/General?

“保存查询结果的默认位置”是否设置为工具/选项/查询结果/SQL Server/常规中的有效路径?

Do the TMP/TEMP environment variables point to valid directories?

TMP/TEMP 环境变量是否指向有效目录?

Reinstalling the client tools will probably fix the problem.

重新安装客户端工具可能会解决问题。

回答by DevJohn

I had this same issue on my Windows 7 machine. I actually encountered the error both in SQL Server Management Studio and Visual Studio 2012. I checked my temp directory and found over 66,000 files. Significantly, there were a large number of files called tmpXXXX.tmp where XXXX was a hex number. The problem was that the files went all the way up to tmpFFFF.tmp. So whatever was creating the temp files was not cleaning them up properly and eventually just ran out of files. The solution was to delete all the files in that folder. Not surprisingly, this also greatly improved performance.

我在 Windows 7 机器上遇到了同样的问题。我实际上在 SQL Server Management Studio 和 Visual Studio 2012 中都遇到了错误。我检查了我的临时目录,发现了 66,000 多个文件。值得注意的是,有大量名为 tmpXXXX.tmp 的文件,其中 XXXX 是一个十六进制数。问题是文件一直到 tmpFFFF.tmp。因此,创建临时文件的任何内容都没有正确清理它们,最终只是用完了文件。解决方案是删除该文件夹中的所有文件。毫不奇怪,这也大大提高了性能。

The temp folder can be found at: %TEMP% which will be correct for both XP and Win7.

可以在以下位置找到临时文件夹:%TEMP% 这对于 XP 和 Win7 都是正确的。

回答by Ravinder

I was facing this problem for a long time.....simple answer for this problem An error occurred while executing batch. Error message is: The directory name is invalidis just free up the disk drive space ....my problem resloved by this may be this will be helpful for many more...

我面临这个问题很长时间了.....这个问题的简单答案An error occurred while executing batch. Error message is: The directory name is invalid就是释放磁盘驱动器空间....我重新解决的问题可能是这对更多人有帮助...

回答by Yuri

I faced the same problem if DB was created in SQL Server 2008 and it was opened by SQL Server 2005. Just reopen it in 2008.

如果 DB 是在 SQL Server 2008 中创建并由 SQL Server 2005 打开,我会遇到同样的问题。只需在 2008 年重新打开它。

回答by user1750216

I was facing the same problem, so to check this i typed %temp% and it gives an error for folder not found .../temp/2 so i created a folder name 2 inside temp folder and restart the sql server.

我遇到了同样的问题,所以为了检查这个,我输入了 %temp% 并且它给出了找不到文件夹的错误.../temp/2 所以我在 temp 文件夹中创建了一个文件夹名称 2 并重新启动 sql server。

which works for me.

这对我有用。

回答by user1750216

I know it can sound like a joke, but have you tried restarting SQL Server instance?

我知道这听起来像个笑话,但是您是否尝试过重新启动 SQL Server 实例?