Convert Oracle SQL line to SQL Server SQL

Hi All,
I'm trying to convert this Oracle SQL to SQL that will work with SQL Server 2008 and am having some trouble with the MOD function. Anyone have any SQL Server chops?
Oracle SQL
TBL_MAIN.AuthoredDate- MOD (TBL_MAIN.AuthoredDate - to_date ('2012-01-01', 'fxYYYY-MM-DD'), 7) + 6 AS "Week Ending"
SQL Server Code
TBL_MAIN.AuthoredDate - ((Cast(TBL_MAIN.AuthoredDate as DATE) % CAST('2012-01-01' AS DATE)), 7) + 6 AS "Week Ending" Thanks,
John
Edited by: Johnbr (Oracle10G) on Mar 1, 2013 8:41 AM

ahhh.. I just had to change my thinking... I got it now:
SQL Server SQL
DATEADD(dd, 7-(DATEPART(dw, TBL_MAIN.AuthoredDate)), TBL_MAIN.AuthoredDate) AS 'Week Ending'

Similar Messages

  • How to convert Oracle *.dmp files into something that SQL can read ?

    Is there a method I can use to convert Oracle *.dmp files into .txt files? .xls files or something??
    Any and all suggestions appreciated!
    Thanks,

    Hi
    you can't convert your .dmp file into text or xls file though you can see the contents of your .dmp file using parameter SHOW=Y in your import command. It will just show the contents of .dmp file and will not import the objects.
    Regards
    Ilyas
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by ():
    Is there a method I can use to convert Oracle *.dmp files into .txt files? .xls files or something??
    Any and all suggestions appreciated!
    Thanks,<HR></BLOCKQUOTE>
    null

  • DB LINK Oracle to SQL Server SQL Server TimeStamp converts to Oracle Date

    Hi All,
    I have created a DB link between Oracle 10g 10.2.0.5 to SQL server 2005 using Oracle 11g gateway. When I execute a query from Oracle that selects data from SQL server using the DBLINK then the column value of type Timestamp from SQL server gets converted to Date data type in Oracle and it losses the time value.
    Is there some way (in gateway configurations or in select query sql ) that the SQL server data type Timestamp gets converted to Oracle's Timestamp?
    Please help.
    Best Regards!
    Irfan
    Edited by: irf_mas on Mar 13, 2012 3:23 AM

    You're getting the ORA-2070 error as the gateway that you are using is not supporting the to_timestamp function in this context. You need to rewrite the code.
    Best would be if you first check out the data format that is sent as a string when you just select the date column - for example:
    data_create_dt
    Jan 11 2012 1:40PM
    Now the easiest way is to make sure the format you are using in your where clause matches the string from the SQL Server:
    select * from "data_ms_view"@FREETDS_DG4ODBC_EMGTW_11_2_0_3 where "data_create_dt"<'Jan 11 2012 1:41PM';
    which will result in:
    data_create_dt
    Jan 11 2012 1:40PM
    BTW,
    it works with all formats the SQL Server understands:
    SQL> select * from "data_ms_view"@FREETDS_DG4ODBC_EMGTW_11_2_0_3 where "data_create_dt">'11-JAN-12 01.40.00.000000000 AM';
    data_create_dt
    Jan 11 2012 1:40PM
    Another way using binds:
    SQL> variable datum varchar2(26);
    SQL> exec select to_char(systimestamp,'MON dd yyyy hh:mi') into :datum from dual;
    PL/SQL procedure successfully completed.
    SQL> print datum
    DATUM
    MAR 19 2012 08:29
    SQL> select * from "data_ms_view"@FREETDS_DG4ODBC_EMGTW_11_2_0_3 where "data_create_dt" <:datum;
    data_create_dt
    Jan 11 2012 1:40PM
    There are several ways to get a result, just make sure you don't use an unsupported function in your statement. A list of supported functions is found in the manual.

  • How to convert Oracle User defined datatype to SQL Server 2014 using SSMA Version 6.0

    I am trying to convert Oracle 11g OE schema to SQL Server 2014, using SSMA version 6.0
    Getting an error in converting the Oracle View to SQL Server
    CREATE OR REPLACE VIEW OC_CUSTOMERS OF OE.CUSTOMER_TYP WITH OBJECT IDENTIFIER (customer_id) AS
    SELECT c.customer_id, c.cust_first_name, c.cust_last_name, c.cust_address,
               c.phone_numbers,c.nls_language,c.nls_territory,c.credit_limit,
               c.cust_email,
               CAST(MULTISET(SELECT o.order_id, o.order_mode,
                                   MAKE_REF(oc_customers,o.customer_id),
                                   o.order_status,
                                   o.order_total,o.sales_rep_id,
                                   CAST(MULTISET(SELECT l.order_id,l.line_item_id,
    l.unit_price,l.quantity,
    MAKE_REF(oc_product_information,
    l.product_id)
    FROM order_items l
    WHERE o.order_id = l.order_id)
                                        AS order_item_list_typ)
                             FROM orders o
                             WHERE c.customer_id = o.customer_id)
                    AS order_list_typ)
         FROM customers c
    *   SSMA error messages:
    *   O2SS0461: Conversion of object view is not supported.
    *   OF OE.CUSTOMER_TYP
    *      WITH OBJECT IDENTIFIER (customer_id)
    CREATE VIEW dbo.OC_CUSTOMERS
    AS
       /*Generated by SQL Server Migration Assistant for Oracle version 6.0.0.*/
       *   SSMA error messages:
       *   O2SS0481: Conversion of statement containing user defined type column 'c.cust_address' not supported.
       *   O2SS0481: Conversion of statement containing user defined type column 'c.phone_numbers' not supported.
       *   O2SS0430: Conversion of multiset conditions is not supported.
       *   CAST(MULTISET
       *      SELECT
       *         o.order_id,
       *         o.order_mode,
       *         MAKE_REF(oc_customers, o.customer_id),
       *         o.order_status,
       *         o.order_total,
       *         o.sales_rep_id,
       *         CAST(MULTISET
       *               SELECT
       *                  l.order_id,
       *                  l.line_item_id,
       *                  l.unit_price,
       *                  l.quantity,
       *                  MAKE_REF(oc_product_information, l.product_id)
       *               FROM order_items  l
       *               WHERE o.order_id = l.order_id
       *            ) AS order_item_list_typ)
       *      FROM orders  o
       *      WHERE c.customer_id = o.customer_id
       *   ) AS order_list_typ)
       SELECT
          c.CUSTOMER_ID,
          c.CUST_FIRST_NAME,
          c.CUST_LAST_NAME,
          c.cust_address,
          c.phone_numbers,
          c.NLS_LANGUAGE,
          c.NLS_TERRITORY,
          c.CREDIT_LIMIT,
          c.CUST_EMAIL,
          NULL
       FROM dbo.CUSTOMERS  AS c   */
    Any suggestion on converting this view would be helpful.
    Kind regards.

    Thanks Lydia Zhang for your reference urls.
    Please let me know if you come across any reference articles related to
    Creating a SQL Server table and View with columns as SQL Server TVP similar to Oracle UDT like
      CREATE TABLE "OE"."CUSTOMERS"
       (    "CUSTOMER_ID" NUMBER(6,0),
        "CUST_FIRST_NAME" VARCHAR2(20 BYTE) CONSTRAINT "CUST_FNAME_NN" NOT NULL ENABLE,
        "CUST_LAST_NAME" VARCHAR2(20 BYTE) CONSTRAINT "CUST_LNAME_NN" NOT NULL ENABLE,
        "CUST_ADDRESS" "OE"."CUST_ADDRESS_TYP" ,
        "PHONE_NUMBERS" "OE"."PHONE_LIST_TYP" ,
        "NLS_LANGUAGE" VARCHAR2(3 BYTE),
    And also creating a SQL Server TVP inside an another SQL Server TVP as in Oracle
    create or replace TYPE customer_typ
     AS OBJECT
        ( customer_id        NUMBER(6)
        , cust_first_name    VARCHAR2(20)
        , cust_last_name     VARCHAR2(20)
        , cust_address       cust_address_typ
       , credit_limit       NUMBER(9,2)
        , cust_email         VARCHAR2(30)
        , cust_orders        order_list_typ
    NOT FINAL;
    Kind regards.
    Venkatesha

  • Convert Oracle "connect by level 10" into MS SQL server 2005

    I want to convert oracle "SELECT LEVEL R FROM CONNECT BY LEVEL <=10" my bottom requirement is  get 1 to 10 as a dynamic table inside a query.
    Ex: Select id, name, R from names N, (1,2,3,4,5,6,7,8,9,10) R WHERE id < 1000 
    If any one know something regarding this please reply me.
    Thx,
    Buddhika

    Hi Buddhika Jayawardhane ,
    Have you sold your problem? I have the same issue to convert from Oracle into SQL Server:
    SELECT all_steps.to_step_id step_id, rownum step_order
    FROM (
    SElECT 0 from_step_id, steps.step_id to_step_id
    FROM steps
    WHERE steps.is_root = 1
    UNION
    SElECT step_transitions.from_step_id, step_transitions.to_step_id
    FROM step_transitions
    ) all_steps
    CONNECT BY all_steps.from_step_id = PRIOR all_steps.to_step_id
    START WITH all_steps.from_step_id = 0
    Please help me find information how to make it!
    Thanks in advance,
    cores

  • Connecting Oracle 9i as a linked server of SQL Server 2000

    I have a problem inserting String values into Oracle 9i as a linked server or SQL Server 2000.
    When I run the following in SQL Analyzer:
    insert into ORACLEOLE..ADMIN.FM_SQL values('asdf','qwer');
    The result msg is:
    Server: Msg 7356, Level 16, State 1, Line 1
    OLE DB provider 'OraOLEDB.Oracle' supplied inconsistent metadata for a column. Metadata information was changed at execution time.
    OLE DB error trace [Non-interface error:  Column 'FM_ID' (compile-time ordinal 1) of object '"ADMIN"."FM_SQL"' was reported to have a DBTYPE of 129 at compile time and 130 at run time].
    Is this a problem that the Charaterset of Oracle 9i being 'ALU32UTF8' ?
    I have tried changing the field's type to varchar2, char, nvarchar2 and nchar...and they didn't work.
    However, when the field type is a number(10) and I insert to the table integer values, the sql works fine.
    so..any data mapping need to be done explicitly?
    Thanks in advance.

    Based on my reading of the ANSI SQL-92 standards, table names are supposed to be in upper case.
    "of course, any lower case letters appearing in a <regular identifier> will have been converted to the corresponding upper case letter before the <identifier> is stored in any table of the Information Schema"
    http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt
    Given that table names are supposed to be in upper case and they are in fact in upper case, why don't you just ask for them in upper case in the first place?

  • Connect Oracle 11g (64-bit windows server) to Microsoft SQL Server 2000

    Hi all,
    I am trying to connect:
    Oracle 11g (64-bit windows server) to Microsoft SQL Server 2000 (32-bit) on a different machine.
    1) I have create an ODBC connection (called:GALAXY) which connects.
    2) created a init.ora called it initgalaxy.ora in $oracle_home\hs\admin
    HS_FDS_CONNECT_INFO = GALAXY
    HS_FDS_TRACE_LEVEL = on
    3) modified the listener.ora file as below
    # listener.ora Network Configuration File: E:\Ora11g\product\11.1.0\db_1\network\admin\listener.ora
    # Generated by Oracle configuration tools.
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = BIU01)(PORT = 1521))
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = IPC)(KEY = extproc0))
    SID_LIST_LISTENER=
    (SID_LIST=
    (SID_DESC =
    (GLOBAL_DBNAME = HEX.BIU01.kingsch.nhs.uk)
    (ORACLE_HOME = E:\Ora11g\product\11.1.0\db_1)
    (SID_NAME = HEX)
    (SID_DESC=
    (SID_NAME = galaxy)
    (ORACLE_HOME = E:\Ora11g\product\11.1.0\db_1)
    (PROGRAM = dg4odbc)
    (SID_DESC =
    (PROGRAM = EXTPROC)
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = E:\Ora11g\product\11.1.0\db_1)
    4) modified the tnsnames.ora file is as follows
    GALAXY =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = BIU01.kingsch.nhs.uk)(PORT = 1521))
    (CONNECT_DATA =
    (SID = galaxy)
    (HS = OK)
    HEX =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = BIU01.kingsch.nhs.uk)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = HEX)
    5) restarted the listener
    6) created a public database connect
    create PUBLIC DATABASE LINK "GALAXY" CONNECT TO "USER" IDENTIFIED by "PWD" USING 'galaxy';
    This is the error message I can sell in $oracle_home\hs\admin\trace
    Oracle Corporation --- MONDAY APR 27 2009 11:54:18.370
    Heterogeneous Agent Release
    11.1.0.6.0
    Oracle Corporation --- MONDAY APR 27 2009 11:54:18.370
    Version 11.1.0.6.0
    HOSGIP for "HS_FDS_TRACE_LEVEL" returned "ON"
    HOSGIP for "HS_OPEN_CURSORS" returned "50"
    HOSGIP for "HS_FDS_FETCH_ROWS" returned "100"
    HOSGIP for "HS_LONG_PIECE_TRANSFER_SIZE" returned "65536"
    HOSGIP for "HS_NLS_NUMERIC_CHARACTER" returned ".,"
    HOSGIP for "HS_FDS_RECOVERY_ACCOUNT" returned "RECOVER"
    HOSGIP for "HS_FDS_TRANSACTION_LOG" returned ""HS_TRANSACTION_LOG""
    HOSGIP for "HS_FDS_TIMESTAMP_AS_DATE" returned "TRUE"
    HOSGIP for "HS_FDS_CHARACTER_SEMANTICS" returned "FALSE"
    HOSGIP for "HS_FDS_MAP_NCHAR" returned "TRUE"
    HOSGIP for "HS_FDS_RESULT_SET_SUPPORT" returned "FALSE"
    HOSGIP for "HS_FDS_PROC_IS_FUNC" returned "FALSE"
    HOSGIP for "HS_FDS_REPORT_REAL_AS_DOUBLE" returned "FALSE"
    using galaxy_live as default value for "HS_FDS_DEFAULT_OWNER"
    HOSGIP for "HS_SQL_HANDLE_STMT_REUSE" returned "FALSE"
    ##>Connect Parameters (len=42)<##
    ## DSN=GALAXY;
    #! UID=galaxy_live;
    #! PWD=*
    hgocont, line 1890: calling SqlDriverConnect got sqlstate IM002
    when I try to test the database link, I get this error:
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Microsoft][ODBC Drive Manager] Data source name not found and no default driver specified
    ORA-02063: preceding 2 lines from GALAXY
    28500.00000- "connection from ORACLE to ad non-Oracle system returned this message:"
    *Cause: The cause is explained in the forwarded message.
    *Action: See the non-Oracle system's documentation of the forwarded message.
    vendor code 28500
    Edited by: user7336435 on 27-Apr-2009 05:56

    11.2 is beta at the moment. There is no official release date so far.
    As DG4ODBC is independant from the Oracle database (or the target database) you can use a 3 machine model:
    On the first machine you have your Oracle database, on a second machine running 32bit Windows you can install DG4ODBC and on the 3rd machine you can run your foreign database.
    If the SQL Server 2k is installed on a 32bit Windows machine, then you can also install DG4ODBC on this machine.
    In general the connection from an Oracle database to the DG4ODBC machine is done using SDQL*Net. The listener responsible for DG4ODBC will then load the DG4ODBC executable which will connect to the SQL Server using SQL Server ODBC driver.

  • Pb with command "Oracle_express\app\oracle\product\11.2.0\server\rdbms\admin\catalog.sql"

    Ello,
    I create a base manually
    when I execute the command
    sqlplus /nolog
    connect /as sysdba
    @Oracle_express\app\oracle\product\11.2.0\server\rdbms\admin\catalog.sql
    a the end I have the error
    Comment created.
    Comment created.
    Grant succeeded.
    DOC>######################################################################
    DOC>######################################################################
    DOC>    The following PL/SQL block will cause an ORA-20000 error and
    DOC>    terminate the current SQLPLUS session if the user is not SYS.
    DOC>    Disconnect and reconnect with AS SYSDBA.
    DOC>######################################################################
    DOC>######################################################################
    DOC>#
    DECLARE
    ERROR at line 1:
    ORA-06553: PLS-213: package STANDARD not accessible
    Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    Somebody have an idea for resolve my issue please ??
    Thank

    TRy this may help u
    CLASSY DBA: ORA-06553: PLS-213: package STANDARD not accessible

  • Load BLOB column in Oracle to Image column in MS SQL Server

    Hi there,
    I have an Oracle table as the source and a MS SQL Server table as the target. A blob(4000) column in source is mapped with a Image(2147483647) column in target.
    The execution will give me error message "*java.lang.NumberFormatException: For input string: "4294967295"* " when it comes to step "load data into staging table"
    The LKM that I am using is LKM SQL to MSSQL.
    I also tried LKM SQL to MSSQL(BULK), LKM SQL to SQL(jython), LKM SQL to SQL. None of them is helpful.
    Coudl anyone tell me how to solve this 4294967295 problem? Thanks a lot

    Hi Yang,
    Oracle recommends the setting of the 'get_lob_precision' flag to FALSE to avoid this error.
    To do that,
    1. Take a backup of your ODIPARAM.BAT file.
    2. Open ODIPARAM.BAT file and add the following line,
    set ODI_ADDITIONAL_JAVA_OPTIONS=%ODI_ADDITIONAL_JAVA_OPTIONS% " -Doracledatabasemetadata.get_lob_precision=false"
    next to,
    set ODI_ADDITIONAL_JAVA_OPTIONS="-Djava.security.policy=server.policy"
    PS:If the parameter is set, the resulting "ODI_ADDITIONAL_JAVA_OPTIONS" ("SNP_ADDITIONAL_JAVA_OPTIONS" or "SNP_JAVA_OPTIONS") should be similar to the above.
    Restart ODI and try.
    Thanks,
    G

  • AIX (Oracle 8.1.6) to MS/SQL Server (ODBC)

    Hi,
    The company I am working for is about to evaluate the Oracle Transparent Gateway to connect 8.1.6 (on AIX) to MS/SQL Server (on NT). I have heard that you can do this via ODBC (on AIX) to ODBC (on NT).
    Does anyone have a step-by-step guide on how to do this? The Oracle documentation
    "Managing Heterogeneous Services Using Generic Connectivity" just gives you concepts and does not tell you how to just
    "do it" or where to get the ODBC driver manager (for AIX) or ODBC driver manager (for AIX).
    Anyone set this up before?

    Hi,
    Good that you are exploreing lot many things. As you are already working on 8.1.6, I guess you know much about that. To get more on 9i features read this link
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96531/toc.htm
    and 9.2.0.4 that 0.4 is a patch which you need to download from metalink site (metalink.oracle.com) for which you needs oracle licence.
    Hope this meets your basic requirement.
    Kamalesh JK

  • Does Oracle have Extended Stored Procedure like SQL Server and Sybase?

    Hi, i am new to Oracle. I want to know if...
    Does Oracle have Extended Stored Procedure like SQL Server and Sybase?
    If it does not have, then how can i call outside program written in C or JAVA from the Database stored procedure or trigger?

    refer to this link on external procedures
    http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76956/manproc.htm#11064

  • Converting Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis

    I could not able to convert Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis.
    I'm connecting OLEDD Oracle Source to OLEDB SQL Destination in SSIS package. I'm trying to insert data from oracle datetime column into sql datetime column. I'm getting some errors.
    Please provide helpful info.

    You can transform the data types directly at the source by writing a proper SQL statement, or you can convert them using the data conversion component.
    Please refer the below link
    http://stackoverflow.com/questions/6256168/how-to-convert-a-timestamp-in-string-format-to-datetime-data-type-within-a-packa

  • Question about creating new tables using SQL script in WebLogic Server

    Hi,
    I am new to WebLogic and I am following a book Java EE Development with Eclipse published by PACKT Publishing to learn
    Java EE.  I have installed Oracle Enterprise Pack for Eclipse on the PC and I am able to log into the WebLogic Server Administration Console
    and set up a Data Source.  However the next step is to create tables for the database.  The book says that the tables can be created using
    SQL script run from the SQL command line.
    I cannot see any way of inputting SQL script into the WebLogic Server Admistration Console.  Aslo there is no SQL Command line in DOS.
    Thanks  for your help.
    Brian.

    Sounds like you are to run the scripts provided by a tutorial to create the tables, right?  In that case, you may need to install an Oracle client to connect to your database.  The client is automatically installed with the database, so if you have access to the server that hosts the database, you should be able to run SQLplus from there.
    As far as I know, there is no way to run a script from the Admin Console.  I could be wrong, however.

  • Problem with the SQL Data Source (Essbase server in Unix Env)

    I too have the same problem.
    I have setup the Datasource for an Oracle db in the Essbase Server (which is on a Unix Box) using the Oracle Wire Protocol.I tested the ODBC connection in the Server and it connect with the credentials.
    But if i choose the same DSN in the EAS and try to connect i get the below error
    Error: 1021001 Failed to Establish Connection With SQL Database Server.
    I even downloaded a document from the Oracle site.. on the SQL interface in Essbase but i could not find the inst-sql.sh file to enable Essbase SQL Interface on the server. Is this required??
    I tried with both the User & System DSN on the server but no luck.
    Any help on this will be highly appreciated. Thanks in advance.
    Posting in a new thread since the old one is answered and no points available to score.

    It can depend on the version, it is different for version 11, further information :- How to define a relational data source in (odbc.ini) V11 Essbase?
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Obiee server SQL throw exception :ORA-29275

    The obiee server throws oracle exception: ORA-29275 while execute in the sql in the bidw , the sql results have Chinese characters
    I have try to copy the sql to query from Jdeveloper adn SQL developer , the sql can run and no exception so does it the NSL_LANG issue in the obiee server side ?
    I also have try to set the NSL_LANG as AMERICAN_AMERICA.AL32UTF8 and AMERICAN_AMERICA.UTF8 , and they seems not worked!
    Odbc driver returned an error (SQLExecDirectW).
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 17001] Oracle Error code: 29275, message: ORA-29275: partial multibyte character at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed. (HY000)

    Any one can help?

Maybe you are looking for