Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

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.
0
Jerry Seinfield
Asked:
Jerry Seinfield
  • 3
  • 2
1 Solution
 
SharathData EngineerCommented:
SET @sql_text=CONCAT("Select * from Table1 into outfile 'C:\\desktop\\",date_format(NOW(),'%Y%m%d'),".csv'");

Open in new window

0
 
Jerry SeinfieldAuthor Commented:
double slash? Interesting...
0
 
SharathData EngineerCommented:
Did it work? did you try?
0
 
Jerry SeinfieldAuthor Commented:
It works, thanks, but now my user has denied access. That's another issue.
I appreciate your help.
0
 
Jerry SeinfieldAuthor Commented:
Thanks for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now