bcp Delimiter Samples





--Double quotes and comma ","   --Option 1 and append " to row delimter with -r \^"\n
DECLARE @cmd5 VARCHAR(4000) 
set @cmd5 = 'BCP  [test1].[dbo].[bcpView] format nul   -f  "C:\temp\myFormatFile2.xml" -x -c -t\^",\^" -r \^"\n -T -S'+ @@servername
exec master..xp_cmdshell @cmd5


--Double quotes and comma ","   --Option 2
DECLARE @cmd5 VARCHAR(4000) 
set @cmd5 = 'BCP  [test1].[dbo].[bcpView] format nul   -f  "C:\temp\myFormatFile2.xml" -x -c -t""",""" -r\^"\n -T -S'+ @@servername
exec master..xp_cmdshell @cmd5


--pipe--Option 1
DECLARE @cmd5 VARCHAR(4000) 
set @cmd5 = 'BCP  [test1].[dbo].[bcpView] format nul   -f  "C:\temp\myFormatFile2.xml" -x -c -t\^|  -T -S'+ @@servername
exec master..xp_cmdshell @cmd5


--pipe --Option 2
DECLARE @cmd5 VARCHAR(4000) 
set @cmd5 = 'BCP  [test1].[dbo].[bcpView] format nul   -f  "C:\temp\myFormatFile2.xml" -x -c -t"|"  -T -S'+ @@servername
exec master..xp_cmdshell @cmd5



 
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s