I have a stored procedure that bulk imports a text file and inserts it into my database.
CREATE TABLE DBO.TEMP_STORE
(
ID NVARCHAR(MAX),
[MONTH] NVARCHAR(MAX),
[YEAR] NVARCHAR(MAX),
STORE NVARCHAR(MAX),
SUBMITTAL NVARCHAR(MAX),
ENTITY NVARCHAR(MAX),
SUBMITTAL_TYPE NVARCHAR(MAX),
iCOUNT NVARCHAR(MAX),
STATE NVARCHAR(MAX),
COUNTRY NVARCHAR(MAX),
REGION NVARCHAR(MAX),
GLOBAL_REGION NVARCHAR(MAX),
LOCAL_CURRENCY NVARCHAR(MAX)
)
--SELECT * FROM DBO.TEMP_STORE
--prepare bulk insert query to load data from file to temp table
SET @SQL='BULK INSERT DBO.TEMP_STORE FROM '''+ @FilePath+''''
SET @SQL=@SQL+'WITH ('
SET @SQL=@SQL+'DATAFILETYPE = ''char'','
SET @SQL=@SQL+'FIELDTERMINATOR = ''|'','
--SET @SQL=@SQL+'ROWTERMINATOR = ''\n'','
SET @SQL=@SQL+'ROWTERMINATOR = ''' + nchar(10) + ''','
SET @SQL=@SQL+'FIRSTROW =2)'
--print @SQL
EXEC (@SQL)
For instance, importing Update ROLLING_CONE_SHOP_DETAIL set SHOP_STATE = 'São Paulo' results in storing the data as'S+úo Paulo' when I select the same row that was imported. I can update the row and explicitly fix the fix the issue:
UPDATE TEMP_STORE
SET STATE = 'São Paulo'
WHERE STATE= 'S+úo Paulo'
But when I do my Bulk insert, it does not retain the special character. I have confirmed the text file I am importing is saved at utf-8 and contains the correct character.
How can I make sure my bulk inset retains the special character properly?
EDIT: This question differs from the "duplicate" question in that I am not looking to import data as UTF-8, I am looking to import data that retains my special characters.
Perhaps removing utf-8 from title would avoid the confusion