Need help formatting BCP output

  • Hello, I have a bcp script that generates stored procedure code output as shown below.

    bcp "select RTRIM(LTRIM(c.text)) FROM sys.objects AS o INNER JOIN sys.syscomments AS c ON o.object_id = c.id WHERE o.type = 'P' AND o.name = 'sp_ic9av0_dx_length'" queryout "\\dbserver1\j$\Backup\NG Sps\sp_ic9av0_dx_length.sql" -t -c -r "\t" -SServer1 -T -dMyDb

    There is a formatting issue in the output script that prevents it from compiling without modifying it first.  I believe it has something to do with a space after the line terminator.  Notice there is a space in the highlighted column name below.  If I simply remove the space, the stored procedure will compile.  Is there a wat to instruct bcp to handle this scenario correctly?

    AND patient_provider_role_.txt_prov ider_role = @provider_role

    Thank you,

    DaveK

     

     

     

  • Try to execute this query with BCP instead of querying the sys.syscomments table:

    SELECT OBJECT_DEFINITION(object_id) FROM sys.objects WHERE type = 'P' AND name = 'sp_ic9av0_dx_length'
    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
  • Thank you HanShi, that worked perfectly!

    DaveK

  • Glad I could help

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply