How to convert sql file to a specific formatted csv file? - sql

Any ideas how I can extract data from a SQL database, put it into a CSV file in a specific format and push it to an external url?

Most SQL databases have some sort of Export utility that can produce a CSV file. Google "Export " and you should find it. It is not a part of SQL standard, so every product does it differently.

Related

How to export blob data values with IBExpert/ IBEscript?

I want to export data from my database to a csv file using IBEscript for a Firebird database. Everything works fine just the columns with blob data don't work. they just miss within the csv file.
When I run the same query in the IBexpert and export the data to csv I check the box "export text blob values" and the data is included. How can I use this option with the script as well?
I need the script since I want an automatic export using the task planer.
Thanks!!!
csv format with blobs makes no sense,since any delimiter (tab,semikolon, etc) can be part of the blob and will destroy your structure.
but automated import/export also with blobs is no real problem in scripts (ibeblock is not available in personal edition)
http://ibexpert.net/ibe/index.php?n=Doc.InsertingFileDataIntoADatabase
http://ibexpert.net/ibe/index.php?n=Doc.IbecLoadFromFile
http://ibexpert.net/ibe/index.php?n=Doc.IbecSaveToFile
Holger
www.ibexpert.com

Exporting data in CSV file format from SQL?

I am trying to export a data table from SQL Server to a .CSV file format, but could not proceed any further after this warning. And I don't know how to fix this, and I need to go further in my job.
Write a query to retrieve the data you want to export
Right click on the result and save as csv file. see image bellow

How to create format files using bcp from flat files

I want to use a format file to help import a comma delimited file using bulk insert. I want to know how you generate format files from a flat file source. The microsoft guidance on this subjects makes it seem as though you can only generate a format file from a SQL table. But I want it to look at text file and tell me what the delimiters are in that file.
Surely this is possible.
Thanks
The format file can, and usually does include more than just delimiters. It also frequently includes column data types, which is why it can only be automatically generated from the Table or view the data is being retrieved from.
If you need to find the delimiters in a flat file, I'm sure there are a number of ways to create a script that could accomplish that, as well as creating a format file.

How can I spool a csv formatted file using an SQL Command?

I have an SQL query that generates a result regarding the daily data from the database. I want a csv formatted file to be generated everyday with this query and saved in a folder. Is there any way I can do this?
NOTE: I am using SQL Server Management Studio 2008 with regards to the DB.
This is a question about bulk export which well documented in MSDN - Importing and Exporting Bulk Data

import csv to sql

I have to import an csv file to SQL database table which already created (empty and has the same number of named columns). It would be great if you could suggest any tutorials or give some tips.
I assume you are using Microsoft SQL Server. Do you need to do this in a program or manually? There is a tutorial on using the bcp command for that, or alternatively a SQL command. If you need to parse the CSV file for your own code, see this previous SO question.