Help and Support

FIX: Bcp.exe with Long Query String Can Result in Assertion Failure

Article ID:279180
Last Review:September 26, 2005
Revision:3.1
This article was previously published under Q279180
BUG #: 56564 (SQLBUG_70)

SYMPTOMS

The Bcp.exe command-line utility will accept a table name or a SELECT query as the source data specification. When using a lengthy SELECT statement, you may receive the following error message:
Assertion failed: sizeof(szCmd) > strlen(szCmd), file ..\src\bcpgetsf.c, line 50

Back to the top

CAUSE

The command line is limited (to approximately 414 bytes). Exceeding the limit causes the assertion failure.

Back to the top

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 7.0. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
301511 (http://support.microsoft.com/kb/301511/EN-US/) INF: How to Obtain the Latest SQL Server 7.0 Service Pack
Note The following hotfix was created before the release of Microsoft SQL Server 7.0 Service Pack 4.


Hotfix

The English version of this fix should have the following file attributes or later:
   File name    Platform
   ---------------------
   BCP917.exe   Intel
				
Note The fix must be applied to the computer where you execute Bcp.exe because it is a client-side fix. Note Because of file dependencies, the most recent hotfix or feature that contains the files may also contain additional files.

Back to the top

WORKAROUND

Create a view that represents the query and use the view name instead of the query.

Back to the top

STATUS

Microsoft has confirmed this to be a problem in SQL Server 7.0.
This problem was first corrected in Microsoft SQL Server 7.0 Service Pack 4.

Back to the top

MORE INFORMATION

The following is an example of Bcp.exe using the SELECT query syntax:
bcp "select au_lname, au_fname from pubs..authors" out c:\temp\delmt.exe -Usa -P -S
				
The problem occurs when the SELECT query is so long that it causes the command to be greater than the 414-byte limitation. After you apply the fix, the limit is approximately 1023 bytes. If you exceed 1023 bytes after you apply the fix, you will receive the following error message:
Query hints exceed maximum command buffer size of 1023 bytes

Back to the top


APPLIES TO
Microsoft SQL Server 7.0 Standard Edition

Back to the top

Keywords: 
kbbug kbfix kbqfe kbhotfixserver KB279180

Back to the top

Article Translations

 

Related Support Centers

Other Support Options

  • Contact Microsoft
    Phone Numbers, Support Options and Pricing, Online Help, and more.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.