• HI

    try this

    declare @sql varchar(8000)

    SET @dir = 'D:\';

    SET @sql = 'bcp "select * from Test.dbo.TableName" queryout "c:\bcptest3.txt " -c -t, -T -S';

    EXEC master..xp_cmdshell @sql;

    Hope this helps 🙂 🙂