You are currently offline, waiting for your internet to reconnect

BUG: Access Violation with xp_cmdshell Returning Data into a Table with More Columns Than Returned

This article was previously published under Q264058
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 57977 (SQLBUG_70)
When an xp_cmdshell extended stored procedure query returns information to a table, if the table is declared with more columns than xp_cmdshell returns, the client receives an Access Violation (AV). The following script:
DECLARE @FileName VARCHAR(100), @DirCmd VARCHAR(150)SET @FileName = 'c:\pagefile.sys'SET @DirCmd = 'dir ' + @FileNameCREATE TABLE #DirFile (Diroutput text, col2 text)INSERT #DirFile  EXEC master.dbo.xp_cmdshell @DirCmd				
returns the following error message:
Server: Msg 213, Level 16, State 7, Procedure xp_cmdshell, Line 5
Insert Error: Column name or number of supplied values does not match table definition.
ODBC: Msg 0, Level 20, State 1
Stored function 'xp_cmdshell' in the library 'xpsql70.dll' generated an
access violation. SQL Server is terminating process 13.
Declare the table with the correct number of columns. In the preceding example, if you remove col2, the query works correctly.
Microsoft has confirmed this to be a problem in SQL Server 7.0.

Article ID: 264058 - Last Review: 11/02/2013 02:18:00 - Revision: 2.0

Microsoft SQL Server 7.0 Standard Edition

  • kbnosurvey kbarchive kbbug KB264058