MySQL Forums
Forum List  »  Microsoft SQL Server

DATETIME COLUMN
Posted by: Nihil Shah
Date: July 16, 2007 10:45AM

I am attempting to migrate 84 tables located in ms-sql to mysql using the mysql migration toolkit. In all of these tables there is a datetime column. The problem is MS-SQL server's Datetime column can hold milliseconds. Mysql's DATETIME column can not hold milliseconds. The obvious solution is to create a seprate interger or varchar field that holds the millisecond data. So I created a SQL script (Bottom of topic) that creates a virtual column called "millisec". Is there any way to execute the sql script on the migration toolkit's source database before the the migration toolkit executes the "creates.sql" script on the target database. If not is there another solution to my problem.

SQL script:

DECLARE @today datetime, @yesterday datetime
SELECT @today = CAST (SUBSTRING(CONVERT(varchar,GETUTCDate(),120),1,10) + ' 00:00:00' AS datetime)
SELECT @yesterday = DATEADD(day, -1, @today)

SELECT
CONVERT(char(19),time_tag,120) AS time_tag,
substring(CONVERT(char(23),time_tag,121),21,3) AS millisec,
S1_QUAL_FLAG,
S1_COUNT,
S1_COUNT_RATE,
S2_QUAL_FLAG,
S2_COUNT,
S2_COUNT_RATE,
S3_QUAL_FLAG,
S3_COUNT,
S3_COUNT_RATE,
S4_QUAL_FLAG,
S4_COUNT,
S4_COUNT_RATE,
S5_QUAL_FLAG,
S5_COUNT,
S5_COUNT_RATE

FROM thetablename
WHERE time_tag >= @yesterday and time_tag < @today
ORDER BY time_tag

Options: ReplyQuote


Subject
Written By
Posted
DATETIME COLUMN
July 16, 2007 10:45AM
March 25, 2009 01:33PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.