Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Getting the text right
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

KilpAr
Yak Posting Veteran

80 Posts

Posted - 10/11/2012 :  12:33:58  Show Profile  Reply with Quote
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
15732 Posts

Posted - 10/11/2012 :  12:47:20  Show Profile  Visit robvolk's Homepage  Reply with Quote
For BULK INSERT you need to specify DATAFILETYPE = 'widechar', otherwise it will translate to non-Unicode before inserting.
Go to Top of Page

KilpAr
Yak Posting Veteran

80 Posts

Posted - 10/15/2012 :  10:58:08  Show Profile  Reply with Quote
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
Go to Top of Page

KilpAr
Yak Posting Veteran

80 Posts

Posted - 10/15/2012 :  11:22:10  Show Profile  Reply with Quote
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.
Go to Top of Page

KilpAr
Yak Posting Veteran

80 Posts

Posted - 10/15/2012 :  12:06:56  Show Profile  Reply with Quote
Yeah, it was about that. Now it works perfectly.

Thanks robvolk for answers!

Edited by - KilpAr on 10/15/2012 12:07:22
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000