?
Solved

Export data from MSSQL server into csv file and publish it on linux webserver - CODEPAGE problem

Posted on 2004-04-06
10
Medium Priority
?
1,363 Views
Last Modified: 2010-05-18
SITUATION:
We have a MSSQL server from which we Export limited amount of data into CSV (comma separated value) file, and publish this data on webserver using linux.

PROBLEM:
The data exported into csv file is not properly shown. Some characters like čćžđš or ČĆŽĐŠ are corupted.
When i look into file with NOTEPAD on Windows - its perfect, but when I look it in Linux its corrupted

QUESTION:
How to export data from MSSQL server into desired codepage (iso-8859-2).

Thanx,

Peter
0
Comment
Question by:petrusko
  • 5
  • 3
  • 2
10 Comments
 

Author Comment

by:petrusko
ID: 10765514
Sory but your editor changed my characters into html chars!

Please help.

Peter
0
 
LVL 34

Expert Comment

by:arbert
ID: 10765625
You can use BCP with the queryout option to export Unicode data to a text file.
0
 

Author Comment

by:petrusko
ID: 10765639
Ok - tell me please what is BCP?

Peter
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 34

Accepted Solution

by:
arbert earned 600 total points
ID: 10765680
0
 

Author Comment

by:petrusko
ID: 10766416
superb - one final question:
How to add field names with bcp?

Peter
0
 
LVL 13

Assisted Solution

by:danblake
danblake earned 400 total points
ID: 10767164
Some characters like čćžđš or ČĆŽĐŠ are corupted.
--> There is a file format difference between Linux Systems and Windows system, you need to convert the file from Windows -> Linux.

Here's a free tool for any other files that you need to convert from ascii windows -> linux.
http://www.thefreecountry.com/tofrodos/index.shtml
0
 
LVL 34

Expert Comment

by:arbert
ID: 10771033
What do you mean add fieldnames with bcp?  With queryout/out you specify the query on the command line "select col1, col2, col3 from yourtable"....

Brett
0
 

Author Comment

by:petrusko
ID: 10772173
To arbert:
When I use BCP I only get data from MSSQL - but not names of fields.

I would like to get field names into first row of CSV file, like this

ID;Addres;Zip;Phone
1;2nd Avenue;12345;01-213-123-321
2;3rd Bulevard;12345;01-321-321-321
.
.
.

0
 

Author Comment

by:petrusko
ID: 10772230
To danblake:
--Tofrodos is a text file conversion utility that converts ASCII files between the MSDOS (or
--Windows) format, which traditionally have CR/LF (carriage return/line feed) pairs as their new
--line delimiters, and the Unix format, which usually have LFs (line feeds) to terminate each line.

tofrodos only converts CR/LF to LF - but it does not convert the data from one codepage to another.

Thanx anyway - Peter
0
 
LVL 13

Expert Comment

by:danblake
ID: 10772468
You can use the BCP utility to specify your code page using -C <code_page id>, if unicode is not required.
BCP only normally creates an independant format file (using the -format), once this has been created can you write a utility to transpose the text from the format file (each line represents a different  column) and then convert this into a single line and append the contents of the second file to the begginig of the first (with the correct row delimiter -- hence the tofrodos).
Or you will need to use something like osql to return a list of headings using a specified column seperator (but this will not necesarily output as the code page you require).

There are also plenty of multi-language unicode code page conversion tools between platforms....(including linux/unix).
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question