Use Window Escape Character ^ for Special delimiters to Work with bcp


Escape Character
^ Escape character.



  & \ < > ^ |
  with escape character ^:

  ^\  ^&  ^|  ^>  ^<  ^^ 

  -t^\
  -t^^^^^&
-- => ^^&

DECLARE @cmd100 NVARCHAR(4000) 
set @cmd100 = 'BCP  [test1].[dbo].[sales] OUT  "C:\temp\sales9.txt"  -c -t^<   -T  -S'+ @@servername
exec master..xp_cmdshell @cmd100

set @cmd100 = 'BCP [test1].[dbo].sales2  IN  "C:\temp\sales9.txt" -c -t^<   -T -S'+ @@servername
exec master..xp_cmdshell @cmd100

 
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