| Author |
Topic  |
|
|
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 10/11/2012 : 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. |
Edited by - KilpAr on 10/11/2012 12:40:15
|
|
|
robvolk
Most Valuable Yak
USA
15557 Posts |
Posted - 10/11/2012 : 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 - 10/15/2012 : 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 äöäöäöäöäöäöä 0
Result in SQL Server looks like this 12 11 õ÷õ÷õ÷õ÷õ÷õ÷õ 0
I have probably some pretty simple error here, any idea what? |
Edited by - KilpAr on 10/15/2012 11:00:01 |
 |
|
|
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 10/15/2012 : 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 - 10/15/2012 : 12:06:56
|
Yeah, it was about that. Now it works perfectly.
Thanks robvolk for answers! |
Edited by - KilpAr on 10/15/2012 12:07:22 |
 |
|
| |
Topic  |
|