User2103319870 posted
SELECT @sqlBCPMerge = 'BCP "SELECT * FROM
DATABASE.dbo.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=' + @tableName + '" queryout ' + @FilePath + ''+ @tableName + 'X.csv -c -t, -T -S '+ @@servername
I think You need to change DataBase to the name of database which you are trying to fetch the columns.
Sample Example for NorthWind Database
SELECT *
FROM Northwind.INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = N'Customers'