?
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,346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

764 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