4

I have N number of tables in my database, which holds around 0.6 million records. I've created a SQL script which copies this data into same tables (basically it's a script to generate more data). I've tested the script it runs fine for small data (10k records). When I tried it to copy all data, it throws an error:

An error occurred while executing batch. Error message is: Error creating window handle.

1.What is the meaning of this error in SQL Server?

2.Does it has to do anything with my SQL in script, or is this cause of other component of SQL Server?

jarlh
  • 42,561
  • 8
  • 45
  • 63
Kylo Ren
  • 8,551
  • 6
  • 41
  • 66
  • 2
    This is a `client side issue`. Reboot the client and check – MusicLovingIndianGirl May 06 '16 at 05:09
  • @MusicLovingIndianGirl I thought that solution is for win forms? Is it the same for SQL server? – Kylo Ren May 06 '16 at 05:12
  • yes it is. Check https://social.msdn.microsoft.com/Forums/sqlserver/en-US/aeae8dc8-f45f-44df-881b-fa9d57948bde/an-error-occurred-while-executing-batch-error-message-is-error-creating-window-handle-sql-server?forum=transactsql – MusicLovingIndianGirl May 06 '16 at 05:21
  • @MusicLovingIndianGirl I check that, is it mentioned somewhere that it solved the problem? I think it was just a proposed solution. – Kylo Ren May 06 '16 at 05:23
  • You can check this too: http://stackoverflow.com/questions/704914/sql-server-an-error-occurred-while-executing-batch-error-message-is-the-dire – MusicLovingIndianGirl May 06 '16 at 05:30
  • @MusicLovingIndianGirl that is some other error. – Kylo Ren May 06 '16 at 05:31
  • You get the problem while running the script via Management Studio or via a custom application? Because as @MusicLovingIndianGirl says it's a client side issue. It's not SQL Server that throws the error. It's the application you use to run the query that throws it. – Allan S. Hansen May 06 '16 at 06:57
  • @AllanS.Hansen I'm running the script from Management Studio. – Kylo Ren May 06 '16 at 06:59
  • Then the error is thrown from Management Studio - not SQL Server. That's what is meant with "client side" issue. Have you tried rebooting? Also check your event viewer for error message that could indicate what the issue is. – Allan S. Hansen May 06 '16 at 07:00
  • @AllanS.Hansen I know now that it's the Management Studio error. I've rebooted but same problem is thrown again. – Kylo Ren May 06 '16 at 07:06
  • Check your event viewer for error message – Allan S. Hansen May 06 '16 at 07:54
  • @AllanS.Hansen it was query output that was causing the problem – Kylo Ren May 06 '16 at 07:57

1 Answers1

3

Handles are Windows tools to manage OS resources. When some app on your machine have memory leaks - you can run out of handles and this error occurs. Current state of handles can be seen in Task Manager (Handle Count)

As said in comments - it's a client side issue. For example large resultsets/query output to grid may end up to this error.

Solution: Reboot your PC, minimize the output of query. Also you can try to launch script via SQLCMD.

You can read more about it here.

Some explanation here.

levininja
  • 3,118
  • 5
  • 26
  • 41
gofr1
  • 15,741
  • 11
  • 42
  • 52