locked
CSV file with headers of a table in SQL RRS feed

  • Question

  • User1210767569 posted

    Aim: Creating BCP with just the headers from the table

    Issue: No headers just a blank csv file

    Code:

    DECLARE @sqlBCPMerge varchar(8000)
    SELECT @sqlBCPMerge = 'BCP "SELECT * FROM DATABASE.dbo.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=' + @tableName + '" queryout ' + @FilePath + ''+  @tableName + 'X.csv -c -t, -T -S '+ @@servername
    EXEC master..xp_cmdshell @sqlBCPMerge  

    Friday, November 20, 2015 4:37 AM

Answers

All replies