views:

281

answers:

3

I just realized my caps was on from working in SQL Server, ha.

Anyways, Im trying to write from

serverName.databaseName.databaseInstanceName.TableName

to

C:\FileName.xml

using bcp and I want to write only columns Col1 and Col2, could I get a little syntax help? I'm struggling over here.

Thanks,

Ted

A: 

In order to create an XML version of the format file the command is identical except we use the -x parameter.

bcp "SELECT col1, col2 FROM AdventureWorks.HumanResources.Department" format nul -c -x -f department.xml -T -S servername
Lukasz Lysik
A: 

thanks, I did google it myself, but again struggling with the syntax. Thats why I put the embolden terms above. I've got it to:

bcp "select col1, col2 from db.dbInstance.Table" format nul -c -x -f c:\test.xml -S localhost -e C:\error.txt -U AD\username

but after I enter my password, all I get is

"An error occurred while processing the command line"

tb
and the error log isnt created
tb
Is AD\username the current user you logged into windows? If yes, use Trusted Connection "-T" instead.
Lukasz Lysik
It is for now(dev/testing), but it will probably be run via script in the future. I also need it to be run as an acct with db_owner, but thats for later .
tb
A: 

FYI for anyone else....

bcp "Select whatever from dbInstanceName.dbo.tableName" quesryout C:\output.txt -e C:\errors.txt -c -T -S localhost\dbName

tb