I’ve been searching the internet for almost 6 hours now for the fastest solution to my problem.
I’ve got a SQL Server database where some of the tables have a DATETIME format for columns, but the values in these columns are in the following format:
DD-MM-YYYY HH:MM
eg.
18-12-2012 00:00
From my research MySQL only accepts the following format for its DATETIME values:
YYYY-MM-DD HH:MM:SS
Now, I’m actually trying to make the conversion in the Scripts themselves, not the database.
basically I have over 250,000 records in multiple tables in SQL Server Script Format.
I’ve already changed all the syntax to MySQL except this part.
Any help or advice would be appreciated. URGENT.
thank you
This is the Table
CREATE TABLE Price(
AirlineCode char(2) NOT NULL
, FlightNumber varchar(6) NOT NULL
, ClassCode char(3) NOT NULL
, TicketCode char(1) NOT NULL
, StartDate DateTime NOT NULL
, EndDate DateTime NOT NULL
, Price decimal NOT NULL
, PriceLeg1 decimal NULL
, PriceLeg2 decimal NULL
, PRIMARY KEY (
AirlineCode,
FlightNumber,
ClassCode,
TicketCode,
StartDate
)
, FOREIGN KEY (AirlineCode) REFERENCES Airlines (AirlineCode)
, FOREIGN KEY (ClassCode) REFERENCES TicketClass (ClassCode)
, FOREIGN KEY (TicketCode) REFERENCES TicketType (TicketCode));
and this is a sample insertion:
INSERT INTO Price VALUES ( 'QF', 'QF67', 'ECO', 'E', '18-12-2012 00:00', '04-01-2013 00:00', 3427.82, 1636.14, 2045.20 );
Edited answer:
Also, you may use RegEx in SQL Server Management Studio:
Find what:
{[0-9][0-9]}\-{[0-9][0-9]}\-{[0-9][0-9][0-9][0-9]} {[0-9][0-9]}\:{[0-9][0-9]}Replace with:
\3-\2-\1