2012年2月23日星期四

Bcp and column delimiters

Where can I get the complet info on Bcp parameters ?
I want to export a table with "$" delimiting columns
what would be the syntax of the bcp command ?You need to use a format file...

Do you know what one looks like?

What version of SQL Server?|||Brett,

If he were executing bcp through query analyzer could he not just use the -t field terminator?

e.g.

bcp database.dbo.tablename out -c -t'$' -r'\n' -Uusername -Ppassword
-Sservername|||Originally posted by rocket39
Brett,

If he were executing bcp through query analyzer could he not just use the -t field terminator?

e.g.

bcp database.dbo.tablename out -c -t'$' -r'\n' -Uusername -Ppassword
-Sservername

oops mispoke, bcp is not run through query analyzer...and documentation for all the of the flags for bcp can be found in BOL by searching on bcp.|||Been working with mainframe flatfiles too long..

And who says you can't do it out of QA?

(Still need to tweak the paramters I'm afraid)

USE Northwind
GO

DECLARE @.cmd varchar(8000), @.username varchar(30), @.password varchar(30), @.File varchar(255), @.Table sysname

SELECT @.username = 'sa', @.password = 'xxx', @.Table = 'Orders', @.File = 'D:\Tax\Order.dat'

SET @.cmd = 'bcp '+ db_name() + '.dbo.' + @.Table + ' out '
+ @.File
+ ' -c -t'
+ '''' + '$' + ''''
+ '-r'
+ '''' + '\nl' + ''''
+ '-U' + @.username +' -P' + @.password +' -S' + @.@.servername

EXEC master..xp_cmdshell @.cmd|||Thanks to both of you,
that will work great I think !

Hey, look I've got a OneStar promotion ! :))|||Originally posted by Karolyn
Hey, look I've got a OneStar promotion ! :))


Who da man...uhh...woman(?)

You go (fill in gender)!

Lots of great SQL stuff out here...

check out..

http://www.sqlteam.com/Default.asp

没有评论:

发表评论