Convert SQL SERVER DATETIME into ORACLE TIMESTAMP

I have to convert a column's datatype.
The source column's datatype is DATETIME which is in SQL Server to TIMESTAMP(datatype in target which is oracle)
Can anyone help me please

Just issue ALTER TABLE MODIFY:
SQL> create table tbl(c date)
  2  /
Table created.
SQL> insert into tbl values(sysdate)
  2  /
1 row created.
SQL> select to_char(c,'mm/dd/yyyy hh24:mi:ss') from tbl
  2  /
TO_CHAR(C,'MM/DD/YY
12/26/2009 20:50:58
SQL> alter table tbl modify c timestamp
  2  /
Table altered.
SQL> select c from tbl
  2  /
C
26-DEC-09 08.50.58.000000 PM
SQL> SY.

Similar Messages

  • ORA-01841 Converting SQL Server DateTime to Oracle Date

    I have Oracle 11gR2 x64 running on my Win7 Enterprise x64 personal system. I'm trying to convert the TSQL to create a database in SQL Server 2008 Express for my C# class to Oracle, and I've run into a "interesting" problem loading date data.
    The SQL Server 2008 TSQL InvoiceDate column in the Invoices table has datatype DATETIME:
    *[InvoiceDate] [datetime] NOT NULL,*
    which Oracle does not support. The Oracle InvoiceDate column in the MMAB_Invoices table has datatype DATE:
    InvoiceDate DATE NOT NULL,
    The fun begins with the TSQL INSERT statements (for example):
    INSERT [dbo].[Invoices] ([InvoiceID], [CustomerID], [InvoiceDate], [ProductTotal], [SalesTax], [Shipping], [InvoiceTotal]) VALUES (18, 20, CAST(0x00009CFD00000000 AS DateTime), 151.0000, 11.3300, 6.2500, 168.5800)
    As you can see, whoever wrote the load script thought it would be totally awesome to convert hex (binary?) data to generate a date, instead of using data readable by a human being.
    BTW, the date generated is 2010-01-13 00:00:00.000.
    After Reading The Fabulous Manual and searching the OTN Discussion Fora, what I came up with is
    INSERT INTO MMAB_Invoices (CustomerID, InvoiceDate, ProductTotal, SalesTax, Shipping, InvoiceTotal) VALUES (20, TO_DATE(UTL_RAW.CAST_TO_VARCHAR2(HEXTORAW('00009CFD00000000')), 'YYYY-MM-DD HH:MI:SS'), 151.0000, 11.3300, 6.2500, 168.5800);
    which returned
    Error starting at line 846 in command:
    INSERT INTO MMAB_Invoices (CustomerID, InvoiceDate, ProductTotal, SalesTax, Shipping, InvoiceTotal) VALUES (20, TO_DATE(UTL_RAW.CAST_TO_VARCHAR2(HEXTORAW('00009CFD00000000')), 'YYYY-MM-DD HH:MI:SS'), 151.0000, 11.3300, 6.2500, 168.5800)
    Error report:
    SQL Error: ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    *01841. 00000 - "(full) year must be between -4713 and +9999, and not be 0"*
    **Cause: Illegal year entered*
    **Action: Input year in the specified range*
    The PK InvoiceID is automatically generated by a BEFORE INSERT trigger that uses a sequence.
    Suggestions?
    Thanks.
    P.S. Happy New Year!!!

    Your hex conversion is certainly not returning a date format:
    sql> select UTL_RAW.CAST_TO_VARCHAR2(HEXTORAW('00009CFD00000000')) from dual;
    UTL_RAW.CAST_TO_VARCHAR2(HEXTORAW('00009CFD00000000'))
      ┐²To convert the hex number to decimal, simply use to_number:
    sql> select to_number('00009CFD00000000', 'xxxxxxxxxxxxxxxx') from dual;
    TO_NUMBER('00009CFD00000000','XXXXXXXXXXXXXXXX')
                                          1.7261E+14Now, before you can make any further calculations with that number, you need to know how it represents the date of 2010-01-13. Luckily, we've got Google nowadays. ;-)
    Sql server representation seems to be an 8 byte field. The first 4 bytes stores the number of days since SQL Server's epoch (1st Jan 1900). The second 4 bytes stores the number of milliseconds after midnight.
    sql> select to_number('00009CFD', 'xxxxxxxxxxxxxxxx') from dual;
    TO_NUMBER('00009CFD','XXXXXXXXXXXXXXXX')
                                       40189
    sql> select to_date('1900-01-01','yyyy-mm-dd') + 40189 from dual;
    TO_DATE('
    13-JAN-10So, the conversion would be something like this:
    sql> select to_date('1900-01-01','yyyy-mm-dd') + to_number(substr('00009CFD00000000',1,8), 'xxxxxxxx') + to_number(substr('00009CFD00000000',9,8), 'xxxxxxxx') / (24*60*60*1000) from dual;
    TO_DATE('
    13-JAN-10Note: Oracle DATE format specifies a datetime up to the second, whereas the sqlserver DATETIME format specifies a datetime up to the millisecond; if that precision is needed, use Oracle's TIMESTAMP instead.
    Note: using an internal representation is risky, implementation details may change. In this case, it seems pretty unlikely that Microsoft will ever change the datetime internal representation, since that would break lots and lots of code.
    Edited by: theoa on 2-jan-2012 9:14

  • Convert  Sql server database into oracle

    hi friends
    i have a very smal database of sql server containing 8 tables
    i want to convert my databse into oracle plz tell me in detail coz i dont know any thing about it.
    plz help me
    take care
    bye

    If the amount of data is small, you might look into Microsoft Data Transformation Services (DTS), which comes with SQL Server. This provides an easy to use GUI for mapping data between two sources.
    A few warnings:
    - If you let DTS create your Oracle tables, beware that that table / column names may be created as case-sensitive and data types may not be what you expect
    - If you are transferring a lot of data (e.g. millions of rows), performance will be terrible.

  • Converting SQL server database into SAP readable XML??

    Could anyone kindly let me know what is the procedure to convert SQL server database into SAP readable (encrypted) XML for SAP Authoring tool???

    Sorry you will need to be more specific, what is it exactly you want to do? What authoring tool do you mean.
    A bit more info and someone might be able to help you.
    BRgds,
    Simon

  • Convert SQL server database into SAP readable (encrypted) XML for SAP tool?

    Could anyone kindly let me know what is the procedure to convert SQL server database into SAP readable (encrypted) XML for SAP Authoring tool???

    So If I understood it correctly there an existing propriertory question bank with SQL server. You are looking at an option to migrate all the tests and questions from the existing system to the LSO system. Right ?
    I am still not clear on the xml conversion. Have you guys found a solution which could be achieved through a xml file ?
    am not aware of a way through which you could import only a xml file and create tests/questions. If you have a sample xml file then forward me so that I could do some testing on my end.As per my knowledge you could do one of the following. I
    1. Create the tests and questions manually in Authoring Environment. It will be a time consuming task. Based on the number of questions you have you might have to assemble a team of content developers to acheive this.
    2. Alternatively, you could create a Adobe Flash based assessment. The Flash component would be the front-end and will read from a xml file to display the questions and to drive the funcationality. This would be a easier and less time consuming than creating the assessments manually in authoring environment. However, you might miss out some of the functionality available in the Test Author of Authoring Environment unless you have all the functionality replicated inside Flash. This would require one time effort in creating the Flash template and the xml file structure. Once that is created you could create multiple assessments by just replacing the xml file. If you select this approach then you would have to ensure the data from SQL is converted in the desired xml format required by your Flash component.
    Please let me know if you require any further guidance or clarification regarding this.
    Regards,
    Ravi Sekhar

  • Convert Sql server Storeprocedure to Oracle Storeprocedure

    Hi I vant to convert a sql server storeprocedures to oracle storeprocedure .
    I need a convertor if anybody know a aplication that performed it please tell me.

    Hi Hoek,
    I have tried this:
    1. Get the DATETIME into a VARCHAR2 variable.
    2a. Then, I use a TIMESTAMP variable and TO_TIMESTAMP like this:
    v_tmst := TO_TIMESTAMP (r_typ.date1, 'DD.MM.YYYY HH24');2b. Or the function CAST:
    v_tmst := CAST (r_typ.date1 AS TIMESTAMP);Same result, I lose the HH:MI:SS.FFF just in the moment the DATETIME from SQL Server is copied into an Oracle VARCHAR2 variable.
    I also read the article you linked (I also read it before I wrote the 1st posting, but not with deep detail).
    I'm afraid this cannot help me, or at least I'm not able to find out how.
    They talk about ODI, but I'm not using that tool.
    Moreover, they talk about creating a table, but they don't say anything regarding the conversion itself and how to get the miliseconds.
    Don't know whether there is something I can take from here or not.
    Anyway, thank you for the repply.
    Francisco.
    Edited by: FranBlanes on 30.08.2012 04:27

  • Problems with loading source model using omw from sql server 7 into oracle 9i

    I am migrating data from sql servr 7 into oracle 9i. when doing capture phase i get the following error.
    ==>failed to load source model.[microsoft][odbc sql server][sql server]select permission
    denied on column 'password' of object 'syslogins', database master, owner dbo.
    Why is this so...is it bcz of something with my odbc link...
    also is there any way to load only tables and not system tables when doing capture phase.
    any help asap will be much appreciated.
    thanks

    Hi,
    You must ensure that you have the correct password to login to SQL Server.
    The Workbench requires some of the tables in the Master database.
    Regards
    John

  • How to export sql server 2000 into oracle intergrally?

    1.environment:
    sql server 200 - character set: CHINESE_PRC_CI_AS
    tables :include ntext field (I think it equals clob)
    support english,simple chinese character.
    oracle 9i - character set :NLS_LANG=AMERICAN_AMERICA.US7ASCII
    2. aim
    export sql server objects(main is tables) into oracle intergrally
    3.question:
    3.1 the field which includes chinese data,after exporting,displays "????" code.
    3.2 how to export sql ntext field into oracle?
    thanks a lot

    You need to setup your Oracle Database use character set that support Chinesre Character. For example a unicode character set AL16UTF16.
    More information her
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14225/ch6unicode.htm#i1006691
    Also consider use Oracle Migration Workbench to transfer SQL Server Data
    http://www.oracle.com/technology/tech/migration/workbench/files/mig_rel10104.html

  • How to import sql server database into oracle

    Hi,
    i have a backup of database(complete) from sql server, Is there any way to import that backup database into oracle environment.
    Please let me know the process
    Thanks
    Naren$

    No. You cannot simply import binary data files from a 3rd party database directly into Oracle.
    You can use bcp on SQL-Server to unload the data to CSV and then use Oracle's SQL*Loader to load it.
    You can run a SQL-Server database instance and an Oracle database instance, and use a heterogeneous database link from Oracle (working via ODBC) to connect to SQL-Server - and use SQL statements to pull object definitions and data from SQL-Server into Oracle.

  • Converting SQL Server 2000 to Oracle 9i

    Hi,
    I am working on the migration of stored procs from a SQL Server 2000 database to Oracle 9i. The sqlsrvr db contains 75 relatively complex procs using temporary tables to create intermediate resultsets for further processing.
    The Oracle 9i environment has very strictly standards and temporary tables are not allowed.
    Is it standard practice to use PL/SQL tables to simulate the functionality of temp tables?
    I understand you can now use SQL against PL/SQL tables under certain circumstances.
    I would envisage using the PL/SQL tables in multi-table joins with schema tables.
    Any ideas whether I am going down the wrong path.
    Thanks in advance,
    Garrett Donnelly

    Garrett,
    Note that there is also an parser option to 'Generate8i temp tables', where the data in the permanent tables is seperated from other sessions by the use of an extra Session id colum.
    Please post the results of your PL/SQL table experiences.
    Regards,
    Turloch
    Oracle Migration Workbench Team

  • Converting SQL Server Query to Oracle

    Hello TechFriends,
    Can any one of u please tell me equivalent of following SQL Server Query?
    The same query runs in Oracle but givesa same reocrds in different order!! I want such an equivalent oracle query that gives records in same order as Sql Server does.
    select
    ProfValue_ProfScaleFK ProfScale,
    ProfValue_Value ProfValue,
    isnull(ProfValueDesc.name, ProfValue_name) ProfName
    from
    ProfValueDesc inner join TBL_LMS_Lang
    on lang_fk = lang_pk and langid = 'en'
    right outer join ProfValue
    on ProfValue_ProfScaleFK = ProfScale_fk and ProfValue_Value = ProfValue_FK ;
    Regards & TIA.
    Anand.

    If you want a specific ordering why don't you add an ORDER BY clause?
    Donal

  • Translate this Sql Server Query into Oracle 9i ?

    UPDATE E
    SET lvl =M.LVL+1
    FROM Employees AS E JOIN inserted AS I
    ON I.empid = E.empid
    LEFT OUTER JOIN Employees AS M
    ON E.mgrid = M.empid

    There is no FROM clause in an ANSI SQL update statement. Folk here don't necessarily know SQL Server, but if you re-write your update statement as an ANSI one and it doesn't work we'll likely be able to help. See page 391 of this doc --
    ANSI SQL 92

  • SQL Server Image to Oracle

    I'm converting SQL Server Tables to Oracle using MWB 9.2. The tables contain images (data type "image"). I get the following error from the MWB generated scripts:
    SQL*Loader-309: No SQL string allowed as part of DISPLAY_IMAGE field specification
    The column definition in the .ctl file is:
    DISPLAY_IMAGE NEXT ***** CHARACTER
    Maximum field length is 2000000
    Terminator string : '<ec>'
    SQL string for column : "HEXTORAW (:DISPLAY_IMAGE)"

    Kelly,
    The OMWB only supports inline data transfer of image types to LONG RAW via SQL*Loader.
    You should be ablr to use TO_LOB() to convert the LONG to LOB.
    The error you have is what you get when you try yo migrate to BLOB. TO use SQL*Loader
    with BLOB you would need to have unload each image into a seperate file and the OMWB
    doen't help you do this. bcp dumps the image data in hex (hence the HEXTORAW sql function),
    I don't know how bcp would dump this as binary.
    Jim.

  • How to convert sql server procedure in to plsql procedure

    hi guys
    i have requirement where in i have to convert sql server procedure into plsql procedure.
    can some one help me out .
    thanks,
    Vamshi.D

    Hi Vamshi,
    As you want to convert sql server procedure in to plsql procedure
    i.e SQL SERVER ->ORACLE Right
    FYI
    SQL SERVER Proc. Syntax are totally different as compared to ORACLE Proc.
    So, better you study Logic of SQL-SERVER Proc and convert into
    Oracle Procedure.
    Thanks,
    Samadhan

  • SQL Server Procedures to Oracle Functions

    Is there an option in the Migration Assistant 1.2.0 that will convert the SQL Server procedures into Oracle Functions (rather than procedures)?
    By default the T/SQL procedures return a integer status code. Our middle-tier requires calls to procedures to return a status code (integer), and I'd like the migration to modify the "procedure" to a "Function returning Integer" rather than Procedure.

    Thomas,
    This is not an option currently. We will look into this for a future release. You could manually make the changes post conversion, prior to generation. As well as adding appropriate RETURN statements, you may want to add additional exception handling so the appropriate error is passed back.
    Donal

Maybe you are looking for

  • How to handle the stale cheques in EBRS

    Dear Guru's Can any bady explain me how to handle the stale cheque cases in EBRS, and what are the possible transaction codes using for that. Any help can be greatly appreciated. Regards, kishroe

  • Image swaps with fade out and in

    I am new to Dreamweaver, in fact only got into it to do my own website. I want to create image swaps with a fade out and then fade in with the new image. Nowhere can I find out how to do this so far. Can anybody point me in the right direction. Many

  • Iphoto 09 major problems - PLEASE HELP!

    Gosh I really hope someone can help me. . I upgraded iphoto 09 this morning and the result has been utter chaos. First I have 3 different iphoto libraries for different years. There are albums from 2 years ago now mixed in the middle of 2009 albums (

  • Has any1 tried the Harman Kardon Drive + Play?

    Ok , i saw this on the apple store, i was wondering if any1 has tried it? I am almost at driving age and i am getting a new truck when i can drive and i want my nano to be incorpurated into it in a cool way. this looks cool, but i just dont know. in

  • Help me in complex function

    I want function by Parameter that when I write into Parameter - for example :- when I write 145 give me 100 when I write 155 give me 200 when I write 150 give me 200 when I write 249 give me 200 when I write 251 give me 300 when I write 250 give me 3