Queries passed to SQL Server are getting corrupted

Posted by adrianbanks on Server Fault See other posts from Server Fault or by adrianbanks
Published on 2010-12-22T12:53:46Z Indexed on 2010/12/22 13:56 UTC
Read the original article Hit count: 221

Filed under:
|

We are experiencing a bizarre error with our application at a customer site. We have managed to narrow it down to the point where we can replicate the behaviour using just Management Studio and SQL Server.

We have two machines, A and B:

+------------+                   +--------------------+
|    [A]     |                   |        [B]         |
| Management |  -------------->  | SQL Server 2008 R2 |
|   Studio   |                   |   Enterprise x64   |
+------------+                   +--------------------+

We are running a SQL script in Management Studio on machine A against the SQL Server instance on machine B. We are not actually executing the script, just parsing it.

Most of the time, the parse operation works fine. Occasionally (seemingly randomly), the parse operation fails with a syntax error. The error message shows the part of the script with the error, which appears as some SQL from the original script that has been truncated and has random characters appended to it.

An example:

The original SQL:

SELECT DISTINCT ST.TABLE_NAME as TableName
FROM INFORMATION_SCHEMA.TABLES AS ST
INNER JOIN INFORMATION_SCHEMA.COLUMNS AS SC
ON SC.TABLE_NAME = ST.TABLE_NAME
WHERE ST.TABLE_TYPE = 'BASE TABLE'
AND SC.COLUMN_NAME = 'Identity'
AND ST.TABLE_NAME != 'dtproperties'
ORDER BY ST.TABLE_NAME

The SQL that is in error (as reported by SQL Server):

SELECT DISTINCT ST.TABLE_NAME as TableName
FROM INFORMATION_SCHEMA.TABLES AS ST
INNER JOIN INFORMATION_SCHEMA.COLUMNS AS SC
ON SC.TABLE_NAME = Sa?

The above example shows how the query is being corrupted. It doesn't always happen, and is not always the same bit of SQL that causes the error. Parsing this script against another SQL Server instance produces no errors, showing that the script is fine.

It appears that something is corrupting the SQL that is being received the the server. This leads me to think that the problem lies either with the client end or in the transmission of the SQL from the client to the server. I have a SQL trace from the period where an error occurs, which shows the SQL has been corrupted when SQL Server receives it.

We have been unable to track down any possible cause of this behaviour, and so cannot find a fix. Because the errors occur seemingly randomly, it is also very hard to generate reproduction steps to submit a bug report.

Any ideas?

© Server Fault or respective owner

Related posts about sql-server-2008

Related posts about Corruption

  • help! corrupt file recovery

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    My supervisor computer crashed last night, and I'm trying to help him out. He made an R script but when he tried to open it, it was empty. But for some reason the file is 7.9kb so it should not be empty i think... anyway when i tried to open it, Gedit gave this error: "The file you opened has… >>> More

  • Login screen restarts while entering password

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I am having a problem that only occurred after installing the fglrx proprietary driver through the additional drivers app. The exact same issue is described in this question, however it's closed. Must login twice before entering Unity; first login screen has graphical anomalies When I boot up my… >>> More

  • Delete corrupted folder

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I am trying to delete a folder in my home directory; its name is completely garbled. In Nautilus, the garbled text is followed by 'Invalid Directory.' Deleting it with Nautilus stalls; I can't type in the garbled name in the terminal. peter@io_vbox:~$ ls -lbdR * ... drwxrwxr-x 3 peter peter … >>> More

  • Error while installing netbeans

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I tried to install NetBeans 7.2 from a downloaded .sh file, but experienced problems. Here's text from the Terminal, which shows what I did and what happened: hridesh@ubuntu:~$ cd Desktop/ hridesh@ubuntu:~/Desktop$ cd full\ netbeans\ 7.2\ for\ linux\ in\ .sh\ format/ hridesh@ubuntu:~/Desktop/full… >>> More

  • How do I fix a corrupted harddrive after failed upgrade?

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    The problem originated when I was trying to fix this problem. Things went horribly, horribly wrong and I ended up with a new problem altogether. The last thing I did was run sudo apt-get install and that caused my system to freeze. I restarted my computer and it would not boot from the harddrive… >>> More