2014-07-14 9 views
-2

En utilisant une requête SELECT en SQL j'ai obtenu des résultats avec beaucoup de lignes et de colonnes. Il affiche bien par des lignes et des colonnes, aucun d'entre eux mélangés.Comment ouvrir le fichier sql .csv?

Cliquez avec le bouton droit dans le coin supérieur gauche et enregistrez sous .csv. Ensuite, j'ouvre ce fichier en utilisant Excel et je vois de nombreux champs ont été mélangés ou les mots, les valeurs vont aux mauvaises colonnes. Savez-vous comment est la bonne façon d'enregistrer le résultat ou comment est le bon moyen d'afficher ce fichier .csv de sql?

Merci.

Mettre à jour comme demandé: J'utilise Microsoft SQL Server Management Studio. Quelques lignes dans mes résultats tableau avant d'enregistrer dans le fichier csv: (contient quelques colonnes ici)

Company Pte Ltd Advanced Materials Technologies Pte Ltd. produces precision metal and ceramic parts. It offers metal hinges, metal packages, intricate cylinders, and valve components; latches and counterweights for hard disk drives; 

ou la ligne avec deux colonnes (premier est le nom de l'entreprise, la deuxième est caractéristique de l'entreprise):

ABC PTE LTD •Project Management
 •Precision Mould Design and Fabrication
 •Multi Colours/Materials Moulding
 •Over Moulding
 •Extreme Thin Wall Compression Moulding
 •Micro Moulding
 

J'ai essayé de cliquer dans le coin supérieur gauche de la table des résultats pour tout sélectionner, puis faites un clic droit et choisissez "copier avec en-tête" puis passé pour exceller. Mais voici quelques problèmes: En SSMS je vois résultat clairement dans ces données:

XYZ Ltd <p> <table border="0" cellspacing="0" cellpadding="0" width="780"> <tbody> <tr> <td valign="top" width="140"> <table border="0" cellspacing="0" cellpadding="0" width="140" height="628"> <tbody> <tr> <td height="628" valign="top" width="140"> <p></p></td></tr></tbody></table></td> <td valign="top" width="500"> <table border="0" cellspacing="0" cellpadding="0" width="500" align="center" height="619"> <tbody> <tr> <td height="619" width="500"> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><b><font color="#333333" face="arial"><span style="FONT-SIZE: 12pt">About Us</span></font></b></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p><img src="http://www.shaofook.com/images/01.jpg" width="240" height="180"> &nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.shaofook.com/images/02.jpg" width="240" height="180"> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><strong><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"><br />Shao Fook Engineering </span></font></strong><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"><b>Pte Ltd </b>was established in March 1989 as a partnership offering contract services for industrial steel fabrication, installation of equipment for oil refineries, petrochemical, industrial plants, turnkey construction project works for factory expansion and most recently the pharmaceutical industry.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We undertake project work from laydown to complete installation of Packaged equipment such as Pipe Rack Structures, Equipment Structures, Flare Stack Structure, Fired Heaters, HRSG, Boilers, Incinerators, Bio-treaters, Cooling Tower as well as Modular equipment such as Compressors, Pumps, Reactors, Silos, Towers, Exchanges, Loading Arms and quick turn around plant maintenance &nbsp;projects.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"></span></font>&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We also perform Laser Alignment of Rotating Equipment.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We have clocked more than 5 million man-hours and handled more than 100,000 Ton of Steel Structure and 50,000 Ton of equipment within customer's budget and schedule. We diligently adhere to safety procedure outlined in our established Work Procedure, Method Statement and Job Safety Analysis.</span></font></p></td></tr></tbody></table></td></tr></tbody></table> <table border="0" cellspacing="0" cellpadding="0" width="780"> <tbody> <tr> <td valign="top" width="140"> <table border="0" cellspacing="0" cellpadding="0" width="140" height="628"> <tbody> <tr> <td height="628" valign="top" width="140"> <p></p></td></tr></tbody></table></td> <td valign="top" width="500"> <table border="0" cellspacing="0" cellpadding="0" width="500" align="center" height="619"> <tbody> <tr> <td height="619" width="500"> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><b><font color="#333333" face="arial"><span style="FONT-SIZE: 12pt">About Us</span></font></b></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p><img src="http://www.shaofook.com/images/01.jpg" width="240" height="180"> &nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.shaofook.com/images/02.jpg" width="240" height="180"> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><strong><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"><br />Shao Fook Engineering </span></font></strong><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"><b>Pte Ltd </b>was established in March 1989 as a partnership offering contract services for industrial steel fabrication, installation of equipment for oil refineries, petrochemical, industrial plants, turnkey construction project works for factory expansion and most recently the pharmaceutical industry.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We undertake project work from laydown to complete installation of Packaged equipment such as Pipe Rack Structures, Equipment Structures, Flare Stack Structure, Fired Heaters, HRSG, Boilers, Incinerators, Bio-treaters, Cooling Tower as well as Modular equipment such as Compressors, Pumps, Reactors, Silos, Towers, Exchanges, Loading Arms and quick turn around plant maintenance &nbsp;projects.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"></span></font>&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We also perform Laser Alignment of Rotating Equipment.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We have clocked more than 5 million man-hours and handled more than 100,000 Ton of Steel Structure and 50,000 Ton of equipment within customer's budget and schedule. We diligently adhere to safety procedure outlined in our established Work Procedure, Method Statement and Job Safety Analysis.</span></font></p></td></tr></tbody></table></td></tr></tbody></table><font color="#333333"><strong><font size="2">Shao Fook Engineering </font></strong><font face="arial"><span style="FONT-SIZE: 9pt"><strong>Pte Ltd </strong>was established in March 1989 as a partnership offering contract services for industrial steel fabrication, installation of equipment for oil refineries, petrochemical, industrial plants, turnkey construction project works for factory expansion and most recently the pharmaceutical industry.</span></font></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We undertake project work from laydown to complete installation of Packaged equipment such as Pipe Rack Structures, Equipment Structures, Flare Stack Structure, Fired Heaters, HRSG, Boilers, Incinerators, Bio-treaters, Cooling Tower as well as Modular equipment such as Compressors, Pumps, Reactors, Silos, Towers, Exchanges, Loading Arms and quick turn around plant maintenance &nbsp;projects.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"></span></font>&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We also perform Laser Alignment of Rotating Equipment.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We have clocked more than 5 million man-hours and handled more than 100,000 Ton of Steel Structure and 50,000 Ton of equipment within customer's budget and schedule. We diligently adhere to safety procedure outlined in our established Work Procedure, Method Statement and Job Safety Analysis.</span></font></p> - Heavy Lifting & Logistic Services - Laser Alignment and Leveling of Rotating Equipment - Industrial Fabrication Work & Plant Maintenance - Equipment Installation for Factories & Industrial Plants - Construction Works - Mechanical (Major), Civil, Electrical - Conveyance & Installation of Material Handling & Production Machines - Heavy Lifting & Logistic Services - Laser Alignment and Leveling of Rotating Equipment - Industrial Fabrication Work & Plant Maintenance - Equipment Installation for Factories & Industrial Plants - Construction Works - Mechanical (Major), Civil, Electrical - Conveyance & Installation of Material Handling & Production Machines 

Mais quand je colle dans Excel je vais obtenir ceci: il y a donc sont

XYZ Ltd <p> <table border="0" cellspacing="0" cellpadding="0" width="780"> <tbody> <tr> <td valign="top" width="140"> <table border="0" cellspacing="0" cellpadding="0" width="140" height="628"> <tbody> <tr> <td height="628" valign="top" width="140"> <p></p></td></tr></tbody></table></td> <td valign="top" width="500"> <table border="0" cellspacing="0" cellpadding="0" width="500" align="center" height="619"> <tbody> <tr> <td height="619" width="500"> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><b><font color="#333333" face="arial"><span style="FONT-SIZE: 12pt">About Us</span></font></b></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p><img src="http://www.shaofook.com/images/01.jpg" width="240" height="180"> &nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.shaofook.com/images/02.jpg" width="240" height="180"> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><strong><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"><br />Shao Fook Engineering </span></font></strong><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"><b>Pte Ltd </b>was established in March 1989 as a partnership offering contract services for industrial steel fabrication, installation of equipment for oil refineries, petrochemical, industrial plants, turnkey construction project works for factory expansion and most recently the pharmaceutical industry.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We undertake project work from laydown to complete installation of Packaged equipment such as Pipe Rack Structures, Equipment Structures, Flare Stack Structure, Fired Heaters, HRSG, Boilers, Incinerators, Bio-treaters, Cooling Tower as well as Modular equipment such as Compressors, Pumps, Reactors, Silos, Towers, Exchanges, Loading Arms and quick turn around plant maintenance &nbsp;projects.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"></span></font>&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We also perform Laser Alignment of Rotating Equipment.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We have clocked more than 5 million man-hours and handled more than 100,000 Ton of Steel Structure and 50,000 Ton of equipment within customer's budget and schedule. We diligently adhere to safety procedure outlined in our established Work Procedure, Method Statement and Job Safety Analysis.</span></font></p></td></tr></tbody></table></td></tr></tbody></table> <table border="0" cellspacing="0" cellpadding="0" width="780"> <tbody> <tr> <td valign="top" width="140"> <table border="0" cellspacing="0" cellpadding="0" width="140" height="628"> <tbody> <tr> <td height="628" valign="top" width="140"> <p></p></td></tr></tbody></table></td> <td valign="top" width="500"> <table border="0" cellspacing="0" cellpadding="0" width="500" align="center" height="619"> <tbody> <tr> <td height="619" width="500"> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><b><font color="#333333" face="arial"><span style="FONT-SIZE: 12pt">About Us</span></font></b></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p><img src="http://www.shaofook.com/images/01.jpg" width="240" height="180"> &nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.shaofook.com/images/02.jpg" width="240" height="180"> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><strong><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"><br />Shao Fook Engineering </span></font></strong><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"><b>Pte Ltd </b>was established in March 1989 as a partnership offering contract services for industrial steel fabrication, installation of equipment for oil refineries, petrochemical, industrial plants, turnkey construction project works for factory expansion and most recently the pharmaceutical industry.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We undertake project work from laydown to complete installation of Packaged equipment such as Pipe Rack Structures, Equipment Structures, Flare Stack Structure, Fired Heaters, HRSG, Boilers, Incinerators, Bio-treaters, Cooling Tower as well as Modular equipment such as Compressors, Pumps, Reactors, Silos, Towers, Exchanges, Loading Arms and quick turn around plant maintenance &nbsp;projects.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"></span></font>&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We also perform Laser Alignment of Rotating Equipment.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We have clocked more than 5 million man-hours and handled more than 100,000 Ton of Steel Structure and 50,000 Ton of equipment within customer's budget and schedule. We diligently adhere to safety procedure outlined in our established Work Procedure, Method Statement and Job Safety Analysis.</span></font></p></td></tr></tbody></table></td></tr></tbody></table><font color="#333333"><strong><font size="2">Shao Fook Engineering </font></strong><font face="arial"><span style="FONT-SIZE: 9pt"><strong>Pte Ltd </strong>was established in March 1989 as a partnership offering contract services for industrial steel fabrication, installation of equipment for oil refineries, petrochemical, industrial plants, turnkey construction project works for factory expansion and most recently the pharmaceutical industry.</span></font></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We undertake project work from laydown to complete installation of Packaged equipment such as Pipe Rack Structures, Equipment Structures, Flare Stack Structure, Fired Heaters, HRSG, Boilers, Incinerators, Bio-treaters, Cooling Tower as well as Modular equipment such as Compressors, Pumps, Reactors, Silos, Towers, Exchanges, Loading Arms and quick turn around plant maintenance &nbsp;projects.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt"></span></font>&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We also perform Laser Alignment of Rotating Equipment.</span></font></p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px">&nbsp;</p> <p style="LINE-HEIGHT: 100%; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"><font color="#333333" face="arial"><span style="FONT-SIZE: 9pt">We have clocked more than 5 million man-hours and handled more than 100,000 Ton of Steel Structure and 50,000 Ton of equipment within customer's budget and schedule. We diligently adhere to safety procedure outlined in our established Work Procedure, Method Statement and Job Safety Analysis.</span></font></p> #NAME? #NAME? 

2 colonnes ne sont pas reconnues et mettre les données erronées:

#NAME? #NAME? 
+0

voulez-vous dire que vous voulez lire ou importer le fichier csv? – stylishCoder

+0

Je veux dire comment pourrais-je lire (ne pas importer) le fichier .csv? Y at-il un lecteur (comme Excel?) Peut le lire dans le même format de table que je vois dans le résultat dans le serveur sql? – user1314404

+0

donc basicall vous voulez lire une table sql au format .csv en utilisant quelle langue .net, php ou quoi? – stylishCoder

Répondre

0

Très probablement, lorsque vous avez enregistré le fichier CSV que vous l'avez fait soit sans délimiteurs sur les champs, ou bien avec un délimiteur qui n'a pas été le guillemet délimiteur requis par Excel (dans ce cas, les guillemets simples les plus probables). Excel exige que tout champ qui contient lui-même une virgule soit placé entre guillemets, sinon il ne peut pas dire où chaque champ se termine dans le fichier et les résultats apparaîtront "mélangés" lorsque le fichier est chargé. Ceci n'est qu'une supposition car vous ne nous avez pas montré un échantillon du fichier CSV que vous rencontrez des problèmes lors du chargement. Si vous deviez montrer même quelques lignes de ce fichier, cela pourrait être plus évident pour nous ce qui se passe. De plus, étant donné que vous n'avez pas mentionné le produit SQL et le frontal que vous utilisez pour créer le fichier CSV, il n'est pas possible de vous conseiller sur la façon de résoudre le problème de citation (si tel est le problème).

+0

Mis à jour ma question pour le rendre plus clair. Votre estimation est très proche de la raison pour laquelle je pense. Peut-être que je peux changer la virgule en quelque chose d'autre comme dans ma requête de sélection maintenant j'utilise: "SELECT", "+ u.description de KeySkills u INNER JOIN Entreprises c ON c.companyId = u.companyId OERE c.companyName = c1.companyName ORDER BY c.companyName POUR XML CHEMIN (''), 1, 1, '') AS listStr "Mais je ne pense pas qu'il puisse résoudre tout le problème car dans les données il a un caractère spécial , Je peux nettoyer cette partie des données. – user1314404

+0

Un certain nombre de choses: 1) vous n'avez pas mentionné que vous étiez en train de créer le format CSV vous-même. Dans ce cas, vous êtes responsable de l'ajout des citations de champs et du dédoublement des citations dans le texte. Mieux vaut tirer les champs que vous voulez et laissez SSMS créer le fichier CSV. 2) Vous avez certainement des virgules internes dans vos valeurs et aurez donc besoin de la citation. –

+0

Alors comment laisser SSMS créer le fichier CSV et comment puis-je mettre le devis? – user1314404

Questions connexes