how to get the number of rows exported through bcp

  • Hi,

    I need to be able to output the number of rows exported through bcp to another file.  Is there a simple way to do this?

    The current code is as follows:

    DECLARE

    @sql varchar(8000)

    SELECT

    @sql = 'bcp "exec stored procedure" queryout Drive:\path\output.csv -T -c -t,'

    EXEC

    master..xp_cmdshell @sql

     

    Help is greatly appreciated

    KR

  • There's no real nice way I know of because it is a process outside of SQL.

    You could do a count on the table but this could be slow.

    You could also insert the results from the XP_CMDShell into a table and grab the rows from there. Will have to do some string manipulation to do this though.

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • That is what I was afraid of.

    Thanks

    KR

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

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