Microsoft KB Archive/264058

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

Article ID: 264058

Article Last Modified on 10/16/2002

-

APPLIES TO


 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q264058



BUG #: 57977 (SQLBUG_70)



SYMPTOMS
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 ' + @FileName CREATE 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.



WORKAROUND
Declare the table with the correct number of columns. In the preceding example, if you remove col2, the query works correctly.



STATUS
Microsoft has confirmed this to be a problem in SQL Server 7.0.

Keywords: kbbug kbpending KB264058

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.