none
Ajuda bcp e xp_cmdshell RRS feed

  • Discussão Geral

  • Estou com o script abaixo e executando normalmente, porém o arquivo não é carregado

    DECLARE @CMD VARCHAR(2500);
    DECLARE @DT CHAR(8)
    
    	SET @DT=CONVERT(CHAR(8),GETDATE(),112)
    
    	SET @CMD = 'BCP "SELECT SINI.UF_MUNIP_SIN, SINI.NAT_SIN_RD, CASOS.* FROM TESTE.DBO.SGF_V_STATUS_CASOS CASOS LEFT OUTER JOIN (SELECT DISTINCT NUM_SIN, UF_MUNIP_SIN, NAT_SIN_RD FROM TESTE.dbo.SGF_T_WF_HIST_AVISOSINISTRO) SINI ON CASOS.SINISTRO = SINI.NUM_SIN" QUERYOUT"C:\REL_CASOS_'+@DT+'.TXT" -S -T -c -t"|"'
    
    	--PRINT @CMD
    	
    	EXEC MASTER..XP_CMDSHELL @CMD

    A mensagem de conclusão é essa:

    NULL
    Starting copy...
    1000 rows successfully bulk-copied to host-file. Total received: 1000
    1000 rows successfully bulk-copied to host-file. Total received: 2000
    1000 rows successfully bulk-copied to host-file. Total received: 3000
    1000 rows successfully bulk-copied to host-file. Total received: 4000
    1000 rows successfully bulk-copied to host-file. Total received: 5000
    1000 rows successfully bulk-copied to host-file. Total received: 6000
    1000 rows successfully bulk-copied to host-file. Total received: 7000
    1000 rows successfully bulk-copied to host-file. Total received: 8000
    1000 rows successfully bulk-copied to host-file. Total received: 9000
    1000 rows successfully bulk-copied to host-file. Total received: 10000
    1000 rows successfully bulk-copied to host-file. Total received: 11000
    1000 rows successfully bulk-copied to host-file. Total received: 12000
    1000 rows successfully bulk-copied to host-file. Total received: 13000
    1000 rows successfully bulk-copied to host-file. Total received: 14000
    1000 rows successfully bulk-copied to host-file. Total received: 15000
    1000 rows successfully bulk-copied to host-file. Total received: 16000
    1000 rows successfully bulk-copied to host-file. Total received: 17000
    1000 rows successfully bulk-copied to host-file. Total received: 18000
    1000 rows successfully bulk-copied to host-file. Total received: 19000
    1000 rows successfully bulk-copied to host-file. Total received: 20000
    1000 rows successfully bulk-copied to host-file. Total received: 21000
    1000 rows successfully bulk-copied to host-file. Total received: 22000
    1000 rows successfully bulk-copied to host-file. Total received: 23000
    1000 rows successfully bulk-copied to host-file. Total received: 24000
    1000 rows successfully bulk-copied to host-file. Total received: 25000
    1000 rows successfully bulk-copied to host-file. Total received: 26000
    1000 rows successfully bulk-copied to host-file. Total received: 27000
    1000 rows successfully bulk-copied to host-file. Total received: 28000
    1000 rows successfully bulk-copied to host-file. Total received: 29000
    1000 rows successfully bulk-copied to host-file. Total received: 30000
    1000 rows successfully bulk-copied to host-file. Total received: 31000
    1000 rows successfully bulk-copied to host-file. Total received: 32000
    1000 rows successfully bulk-copied to host-file. Total received: 33000
    1000 rows successfully bulk-copied to host-file. Total received: 34000
    1000 rows successfully bulk-copied to host-file. Total received: 35000
    1000 rows successfully bulk-copied to host-file. Total received: 36000
    1000 rows successfully bulk-copied to host-file. Total received: 37000
    1000 rows successfully bulk-copied to host-file. Total received: 38000
    1000 rows successfully bulk-copied to host-file. Total received: 39000
    1000 rows successfully bulk-copied to host-file. Total received: 40000
    1000 rows successfully bulk-copied to host-file. Total received: 41000
    1000 rows successfully bulk-copied to host-file. Total received: 42000
    1000 rows successfully bulk-copied to host-file. Total received: 43000
    1000 rows successfully bulk-copied to host-file. Total received: 44000
    1000 rows successfully bulk-copied to host-file. Total received: 45000
    1000 rows successfully bulk-copied to host-file. Total received: 46000
    1000 rows successfully bulk-copied to host-file. Total received: 47000
    1000 rows successfully bulk-copied to host-file. Total received: 48000
    1000 rows successfully bulk-copied to host-file. Total received: 49000
    1000 rows successfully bulk-copied to host-file. Total received: 50000
    1000 rows successfully bulk-copied to host-file. Total received: 51000
    1000 rows successfully bulk-copied to host-file. Total received: 52000
    1000 rows successfully bulk-copied to host-file. Total received: 53000
    1000 rows successfully bulk-copied to host-file. Total received: 54000
    1000 rows successfully bulk-copied to host-file. Total received: 55000
    1000 rows successfully bulk-copied to host-file. Total received: 56000
    1000 rows successfully bulk-copied to host-file. Total received: 57000
    1000 rows successfully bulk-copied to host-file. Total received: 58000
    NULL
    58298 rows copied.
    Network packet size (bytes): 4096
    Clock Time (ms.) Total     : 56047  Average : (1040.16 rows per sec.)
    NULL

    Porque o arquivo não é carregado?

    Att:Daniel


    Daniel

    sexta-feira, 10 de agosto de 2012 18:03

Todas as Respostas

  • Galera,

    alguma ideia?

    Att:Daniel

    Daniel

    segunda-feira, 13 de agosto de 2012 12:33
  • Pô rapaziada, desculpem pela insistência. Alguem poderia dar uma força?

    Att:Daniel

    Daniel

    terça-feira, 14 de agosto de 2012 12:33
  • Fala dralves;

    Tente remover as aspas duplas após o QUERYOUT:

    DECLARE @CMD VARCHAR(2500);
    DECLARE @DT CHAR(8)

    SET @DT=CONVERT(CHAR(8),GETDATE(),112)

    SET @CMD = 'BCP "SELECT SINI.UF_MUNIP_SIN, SINI.NAT_SIN_RD, CASOS.* FROM TESTE.DBO.SGF_V_STATUS_CASOS CASOS LEFT OUTER JOIN (SELECT DISTINCT NUM_SIN, UF_MUNIP_SIN, NAT_SIN_RD FROM TESTE.dbo.SGF_T_WF_HIST_AVISOSINISTRO) SINI ON CASOS.SINISTRO = SINI.NUM_SIN" QUERYOUT C:\REL_CASOS_'+@DT+'.TXT -S -T -c -t"|"'

    --PRINT @CMD

    EXEC MASTER..XP_CMDSHELL @CMD

    Abs.


    View Ricardo Muramatsu's profile on LinkedIn

    segunda-feira, 20 de agosto de 2012 14:54
  • Obrigado Ricardo! Funcionou.

    Daniel

    quinta-feira, 23 de agosto de 2012 13:40