Solved

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

Posted on 2004-04-06
10
1,326 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
Comment Utility
Sory but your editor changed my characters into html chars!

Please help.

Peter
0
 
LVL 34

Expert Comment

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

Author Comment

by:petrusko
Comment Utility
Ok - tell me please what is BCP?

Peter
0
 
LVL 34

Accepted Solution

by:
arbert earned 300 total points
Comment Utility
0
 

Author Comment

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

Peter
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 13

Assisted Solution

by:danblake
danblake earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now