in

UGISS Community

Il sito della community dello User Group Italiano di SQL Server

xp_cmdshell e bcp

Last post 07-09-2008 17.47 by sgovoni. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-08-2008 19.29

    • sgovoni
    • Top 10 Contributor
      Male
    • Joined on 10-18-2007
    • Posts 147
    • Points 2.230

    xp_cmdshell e bcp

    Ciao a tutti,

    sto utilizzando l'utility bcp, con SQL Server 2000, per esportare il result set di una query su file DBF.

    Quando eseguo il comando:

    EXEC MASTER..XP_CMDSHELL 'bcp "Select ... From ... Where ..." queryout C:\FileName.dbf -c -s SERVER'

    ricevo l'errore:

    "Query hints exceed maximum command buffer size of 1023 bytes (1213 bytes input)."

    Nei books online ho letto che xp_cmdshell accetta il parametro command_string di tipo varchar(255) oppure nvarchar(4000), il comando che eseguo ha una lunghezza minore di 4000 caratteri.

    Avete qualche suggerimento da darmi ?

    Altrimenti utilizzo una tabella temporanea ed estraggo i dati da quella nel comando bcp.

    Grazie

    Filed under:
    • Post Points: 20
  • 07-09-2008 8.23 In reply to

    • dmauri
    • Top 10 Contributor
      Male
    • Joined on 05-14-2007
    • Novate Milanese
    • Posts 1.028
    • Points 13.275

    Re: xp_cmdshell e bcp

    ciao Sergio

    il problema non è XP_CMDSHELL ma il tool BCP, la cui query può essere lunga al massimo 1023 bytes. Devi quindi mettere la tua query in una vista e quindi usare quella.

     

    Davide Mauri
    Microsoft MVP - SQL Server, MCP, MCAD, MCDBA, MCT - http://www.davidemauri.it
    Socio Fondatore e Mentor di Solid Quality Learning Italy - http://www.solidq.com
    Presidente di UGISS: User Group Italiano Sql Server - http://www.ugiss.org
    • Post Points: 20
  • 07-09-2008 17.47 In reply to

    • sgovoni
    • Top 10 Contributor
      Male
    • Joined on 10-18-2007
    • Posts 147
    • Points 2.230

    Re: xp_cmdshell e bcp

    Grazie Davide,

    ottima l'idea della vista Big Smile.

    Ciao

    Filed under:
    • Post Points: 5
Page 1 of 1 (3 items)
(C) 2007 User Group Italiano di SQL Server