Ramu K
Ramu K

Reputation: 19

How to work with BCP

I am connecting to sql server which is in another server from my server.

I am executing the following:

Exec master..xp_cmdshell 'bcp "select * from databasename.dbo.tablename " 
queryout "D:\tempexportfile.txt" -c -t, -T -S[Connected servername]'

it is writing the text file in the connected server from my server, but i want to the text file is in my server,

Is there any posibility to specify my current server and write text file here?

Upvotes: 0

Views: 134

Answers (1)

Jaques
Jaques

Reputation: 2287

On the server that you execute the bcp on should connect via a share drive to your server. Then replace the D:\ with the share drive letter.

Another way is to make sure that you have a share on your server that is accessible from the SQL Server, then replace the D:\ with \yourservername\sharename.

Hope that helps.

Upvotes: 1

Related Questions