Link to home
Start Free TrialLog in
Avatar of Jerry Seinfield
Jerry SeinfieldFlag for United States of America

asked on

How can I include today's date in filename .csv when using OUTFILE using MySQL

I need to create export a csv file that should be named with date i.e. file20160811.csv

I have my query.
I tried this:
SET @sql_text = CONCAT("Select * from Table1 into outfile 'C:\desktop\",date_format(NOW(),'%Y%m%d'),".csv'");
PREPARE statement FROM @sql_text;
EXECUTE statement;

I got  error Code 1064, error SQL syntax...

can someone help me to fix this?

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jerry Seinfield

ASKER

double slash? Interesting...
Did it work? did you try?
It works, thanks, but now my user has denied access. That's another issue.
I appreciate your help.
Thanks for your help