SQL Server Performance

Count Rows for CSV file

Discussion in 'SQL Server 2008 General DBA Questions' started by Guestuser31, Aug 27, 2009.

  1. Guestuser31 New Member

    HI
    I have the following code below. I am trying to display the countrows variable in the CSV file but it is not displaying, only the first query is displaying. How can I get both to display?
    ThanksALTER PROCEDURE [dbo].[PROCEDURE]

    AS
    BEGIN
    select field1,field2 from table
    declare @sql varchar(8000)
    select @@rowcount
    select @sql = 'bcp "exec PROCEDURE" queryout C:cppro.txt -c -t, -T -S'+ @@servername

    exec xp_cmdshell @sql


    END
  2. Madhivanan Moderator

    Do you want to append the rowcount at the end of the file?
  3. Guestuser31 New Member

    I just need to show the amount of rows returned from the query in the CSV file, if that answers your question?!
  4. Madhivanan Moderator

    [quote user="Guestuser31"]
    I just need to show the amount of rows returned from the query in the CSV file, if that answers your question?!
    [/quote]ALTER
    PROCEDURE [dbo].[PROCEDURE] AS
    BEGIN
    select field1,field2 from table
    declare
    @sql varchar(8000)
    select @sql = 'bcp "exec PROCEDURE" queryout C:cppro.txt -c -t, -T -S'+ @@servername
    exec xp_cmdshell @sql
    select @@rowcount

Share This Page