Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 2012-10-11 : 12:33:58
|
This might be a stupid question, but how do I save text in SQL Server? Specifically I need to make fields that can handle cyrillic and scandinavian alphabets, I tried by defining the datatype as nvarchar, it doesn't recognize either ä or ö, ö appears as dividing mark (something like dot over a line over a dot) and ä appears as õ (that is, a tilde over an o). I thought nvarchar would handle these problems, I also thought I could just define collation as UTF-16 or whatever, but SQL Server 2008 R2 (and it's management studio) doesn't give me any UTF-options in TableDesigner-Collation when editing the design.edit. The problem occurs when doing a BULK INSERT, the txt-file I use to import the text from looks fine. |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-10-11 : 12:47:20
|
For BULK INSERT you need to specify DATAFILETYPE = 'widechar', otherwise it will translate to non-Unicode before inserting. |
|
|
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 2012-10-15 : 10:58:08
|
My Excel VBA code for compiling that statement looks now like this:strsql = "BULK Insert dbo.Comments FROM ""F:\CostControl\" & strTRFile & """ WITH (FIELDTERMINATOR = '\t',ROWTERMINATOR = '\n',DATAFILETYPE = 'widechar')"Content in that txt-file looks like this:12 11 äöäöäöäöäöäöä 0Result in SQL Server looks like this12 11 õ÷õ÷õ÷õ÷õ÷õ÷õ 0I have probably some pretty simple error here, any idea what? |
|
|
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 2012-10-15 : 11:22:10
|
I think it is because the txt-file I write from VBA doesn't support UTF-8. i'll get back after I fix that part. |
|
|
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 2012-10-15 : 12:06:56
|
Yeah, it was about that. Now it works perfectly.Thanks robvolk for answers! |
|
|
|
|
|
|
|