Use Unicode Native Format to Export/Import Data with bcp/Bulk Insert


--Use Unicode Native Format to Import or Export Data 
DECLARE @cmd10N NVARCHAR(4000) 
set @cmd10N = 'BCP  [test1].[dbo].[address] OUT  "C:\temp\address_N.txt"  -N -T  -S'+ @@servername
exec master..xp_cmdshell @cmd10N , no_output

--set @cmd10N = 'BCP [testdb].[dbo].address  IN  "C:\temp\address_N.txt" -N -b 100000  -T -S'+ @@servername 
--exec master..xp_cmdshell @cmd10N , no_output
 
BULK INSERT  testdb.[dbo].[address]
    FROM 'C:\temp\address_N.txt' 
   WITH (DATAFILETYPE='widenative'); 
 
--SELECT count(*)  FROM  testdb.[dbo].[address];
 

 

http://msdn.microsoft.com/en-us/library/ms189941.aspx

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