i have tried the following command to write a text file from a table:
EXEC master..xp_cmdshell 'bcp "SELECT * FROM DB.dbo.table1" queryout "C:\employee.txt" -T -Sservername -U user111 -P pwd -c -t,'No file is created, I am not sure why. Can anyone pls help?
I am not getting errors instead I get following messages:
usage: bcp {dbtable | query} {in | out | queryout | format} datafile [-m maxerrors] [-f formatfile] [-e errfile] [-n native type] [-c character type] [-w wide character type] [-N keep non-text native] [-V file format version] [-q quoted identifier] [-C code page specifier] [-t field terminator] [-r row terminator] [-i inputfile] [-o outfile] [-a packetsize] [-S server name] [-U username] [-P password] [-T trusted connection] [-v version] [-R regional enable] [-k keep null values] [-E keep identity values] NULL
the query was correct –
while typing in SQL SERVER MANAGEMENT studio I pressed enter after queryout so statement “C:\employee.txt” -Sservername -U user111 -P pwd -c -t,’ was coming in next line. because of this I was not getting any error or output file