Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Output to .csv
Message
 
À
20/08/2004 07:33:22
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Titre:
Divers
Thread ID:
00934625
Message ID:
00935102
Vues:
27
The script in the link creates a procedure (after deleting any previously existing one with the same name), that creates a string with a BCP command that requests five fields from the Authors table in the sample Pubs database and exports that data to a CSV file. It then calls the system stored procedure xp_cmdshell with the formulated BCP command that shells out to the operating system (DOS prompt) and executes the command. The data is placed into c:\temp\authors.csv.

Note that this only creates the procedure. It would then need to be executed.

BCP is a command-line utility that comes with SQL Server for doing bulk copies of data into and out of SQL Server.

I've given you three options, thus far, depending upon your circumstances and needs:
1. Data Transaction Services (DTS) (Easiest way with a good GUI.) DTS can be found as the option between Databases and Management in SQL Server Enterprise Manager. (If you right-click on a table and select All Tasks->Export Data (or Import Data) you will get a simplified DTS for simple import/export of a single table with no bells or whistles.) DTS from the menu, however, has much more power.
2. BCP from the DOS command line. (Good for basic manual imports and exports. Very fast.)
3. Use of BCP through a stored procedure through the use of shelling to DOS prompt. (Possible, but not recommended for a wide variety of reasons. Use only as a last resort and be prepared for frequent headaches if you try to implement in a production environment.)

DTS is your best bet. What are you trying to do?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform