Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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,356 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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
Via a live example, show how to shrink a transaction log file down to a reasonable size.

636 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