Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • 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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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