I have a MySQL-Database with several rows. In that environment, I stored the current time as a Timestamp (int
).
Now I need to migrate my data from a MySQL to a T-SQL-Database. I'm running SQL-Server 2008.
I checked several approaches, but couldn't come up with a way which transforms my int into a smalldatetime format.
Is there a build-in function for this? Is this even doable alone in a statement? I really don't want to write a PHP-snippet, which converts the timestamp to the desired format.
Thanks in advance
As per the documentation,
smalldatetime
uses the following format:So, we need to convert the
MySQL
timestamp intodate
and format it in the above format to getsmalldatetime
. This can be done by usingFROM_UNIXTIME
andDATE_FORMAT
functions ofMySQL
, e.g.:Here's the SQL Fiddle.