
December 29th, 2012, 10:42 PM
|
 |
Contributing User
|
|
|
|
I've actually been able to do this with some vb script and DOS...
Example I create a "CreateSQL.vbs" file with notepad
Code:
' Wscript.Echo DateAdd("d",-1,Now)
Dim LMon
LMon = DateAdd("d",(WeekDay(Date())-2)*-1,Date())
dim filesys, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("F:\PathToSQL\CreatePDTable.sql", True)
path = filesys.GetAbsolutePathName("F:\PathToSQL\CreatePDTable.sql")
getname = filesys.GetFileName(path)
filetxt.WriteLine("DROP TABLE IF EXISTS PARTDATA.TBLPD" & Year(LMon) & Right("0" & Month(LMon),2) & Right("0" & Day(LMon),2) & ";")
filetxt.WriteLine("")
filetxt.WriteLine("CREATE TABLE PARTDATA.TBLPD" & Year(LMon) & Right("0" & Month(LMon),2) & Right("0" & Day(LMon),2))
filetxt.Close
and then I call it with a DOS .bat file like
F:\PathToFile\CreateSQL.vbs
and then in the DOS .bat file I call the .sql file that's created like:
C:\xampp\mysql\bin\mysql -u root -password -D databasename < "F:\PathToSQL\CreatePDTable.sql"
|