Reputation: 31
I have a SQL database and want to write a script, which saves the table "European_option_info" as a txt (or excel) file to a local folder.
I use the following code:
use database;
select * into outfile 'C:\[...]\Dropbox\Employees.txt' FIELDS TERMINATED BY ';' from European_option_info;
This gives me the following error:
"Error Code: 1. Can't create/write to file 'C:[]\Employees.txt' (Errcode: 22)"
Regards, Daniel
Upvotes: 1
Views: 149
Reputation: 15644
One problem may be of the file path that your are specifying, you need to to specify entire path and also that file must not be open when executing this query.
The other problem may be of permission to create/change something in C:\\
( Here I am assuming that you are using Windows OS and if not then just try this solution for other OS as well) as it may require administrative rights
as the application that is executing your query may not be in run as administrator
mode of windows. (Assuming C:
drive contains your windows installation).
So try changing the directory to some other directory of your PC.
Upvotes: 1
Reputation: 2430
It looks like your file name is incorrect. Use a full path for the path to Employees.txt.
For example
USE database;
SELECT * INTO OUTFILE 'C:\Users\Username\Dropbox\Employees.txt'
FIELDS TERMINATED BY ';'
FROM European_option_info;
Or whatever the full path to your Dropbox folder is.
Upvotes: 1