Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Excel attachment with DBMail

Author  Topic 

bhaskar.rm
Starting Member

6 Posts

Posted - 2009-09-10 : 05:06:50
XP_cmdshell 'bcp.exe -Q"Query" -o C:\Filepath.xls -c -T'.

i Cannot be able to execute this code..

It showing Error


Copy direction must be either 'in', 'out' or 'format'.
usage: bcp.exe {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-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]


Bhaskar

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-10 : 06:34:17
Are you trying to export data to EXCEL file?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

bhaskar.rm
Starting Member

6 Posts

Posted - 2009-09-10 : 08:38:13
yes i am trying to export the query result to excel file

Bhaskar
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-10 : 08:54:38
Refer this
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

bhaskar.rm
Starting Member

6 Posts

Posted - 2009-09-11 : 01:47:11
thanks Madhivanan. It helped me a lot!



Bhaskar
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-11 : 02:50:31
quote:
Originally posted by bhaskar.rm

thanks Madhivanan. It helped me a lot!



Bhaskar


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -