简体   繁体   中英

To_Date Function Migration from oracle to SQL Server

I am migrating my oracle database to SQL Server. What is the easiest way to convert to_date functions? I have many sql which use to_date .

For example I have an update query. It contains following line.What can be solution to convert it to SQL Server 2008 with minimum effort?

Sample Query Line

LAST_LOGIN=to_date('" & m_LAST_LOGIN & "','DD.MM.YYYY HH24:MI:SS') ") 
LAST_LOGIN = convert(datetime, m_LAST_LOGIN, 20)

You can find further information from

http://msdn.microsoft.com/en-us/library/aa226054(SQL.80).aspx

This page contains useful conversion information. From what you've given, the following should suffice. (Used with getdate() as an example date)

declare @LAST_LOGIN varchar(21)
set @LAST_LOGIN = convert(varchar(10), getdate(), 104) + ' ' +convert(varchar(10), getdate(), 108)

There is nothing directly to convert it to the format you specify, so you have to concatenate the two conversions as shown above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM