Data Conversion or Sql Command

We are importing mdb data to SQL Server and require data type casting. Which is better to use and gives better performance?
- Data Conversion
- SQL Command (with casting)
Thanks,
Darren

Using the sql cast will give you a performance benefit over using the data conversion transformation.  We should probably shelve the transformation unless if we are in a situation where we can’t return the data with the type we would like for the destination
(ex. flat files or stored procedures).
Check this short and sweet article :
here
If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

Similar Messages

  • Optional Date parameters in SQL Command

    I'm using Crystal Reports 2008. I want to make the start and end date parameters optional and have them default to the beginning and end of the previous month. Unfortunately, I'm using an SQL Command, rather than filtering in the Record Selection Formula, and I can't see any way to pass the computed start and end dates into the query. Is there any way to get the results I want short of omitting the date parameter in the query and doing all the filtering on the front end? Thanks.

    The way I have gotten around this problem is to make the date parameters strings, and allow mnemonics such as PM for prior month, PD for prior day, PQ for prior quarter, etc.  I then wrote Crystal and database functions that convert these mnemonics to actual dates, which are then used where necessary.  This is also useful for scheduling the same report to run weekly (for the prior week), monthly (for the prior month) and quarterly (for the prior quarter)...
    Also, remember that an SQL command in Crystal is basically the equivalent of a stored procedure, so you can do a lot of logic in them before returning your data set.  So, in your SQL, you could set a variable to either the parameter value or a calculated prior month dependent on if the date parameter is null (assuming Crystal allows no entry for the parameter, which I think 2008 does [I'm on XI R2]).
    HTH,
    Carl

  • Converting Crystal Date Group to SQL Command

    When selecting the option to group on the server, I found that there are requirements in addition to selecting the option.
    I have a date grouping in Crystal like the following:
    dateadd("d", - weekday({table.date}, crMonday)+1,{table.date})
    Can this be converted to a SQL command?

    Hi Mark,
    Jyothi had given  an excellent query for you,  Congrats Jyothy!!
    But she didnt mantioned 'From clouse' on that.
    Let me correct that query with an example,
    My TableName: Invoice
    Primary Key: InvoicePID
    Date field:InvoiceDate
    Here the query will be
    select InvoicePID,  Dateadd(d,-(CASE  WHEN DATEName(dw,Invoice.InvoiceDate ) = 'Monday' THEN 1
                            WHEN DATEName(dw,Invoice.InvoiceDate ) = 'Tuesday' THEN 2     
                             WHEN DATEName(dw,Invoice.InvoiceDate ) = 'Wednesday' THEN 3
                             WHEN DATEName(dw,Invoice.InvoiceDate ) = 'Thursday' THEN 4
                             WHEN DATEName(dw,Invoice.InvoiceDate ) = 'Friday' THEN 5
                             WHEN DATEName(dw,Invoice.InvoiceDate ) = 'Saturday' THEN 6
                             WHEN DATEName(dw,Invoice.InvoiceDate ) = 'Sunday' THEN 7
    END
    )+1 ,Invoice.InvoiceDate)
    from Invoice
    You can change the tablename and field with respect to your DB.
    regards,
    Salah.

  • Strange caching on a paging enabled data table when sql-command changes

    Got some strange results when changing the command property of a JdbcRowSetXImpl. To reproduce:
    - create new jsp page
    - drag a table from Data Sources onto the page design grid
    - put a DataTable on the page design grid
    - bind DataTable to the RowSet for the table from step 2
    - enable paging on the DataTable; make sure the page is smaller than the number of items in the table. Also add the page navigation buttons
    - add a read-write property 'query' to SessionBean1
    - add a button to the page design grid
    - double click button and add
    getSessionBean1().setQuery("SELECT * FROM <table> ORDER BY <someColumnName>"); // replace <> strings with appropriate names
    - change the command property / query string for the table in the page backing bean to getSessionBean1().getQuery();
    - run application
    - click on button with query change code 'behind it'
    - click on '->' next page button
    - click on '<-' previous page button
    Notice that one page is sorted, the other not. All pages that have been displayed before the 'query change' button was pressed remain in the 'old' sort order.
    I have tried to call xxxRowSet.execute(), dataTable1Model.getDataCache().reset() on several places, to no avail.
    The only hack I found to be working was adding a private static int hackCounter, and changing the ctor to dataTable1Model.setDataCacheKey("com.sun.datacache.bug.xxxRowSet" + hackCounter++);
    Clearly there must be a better solution.

    did u try dataTable1Model.execute();
    you didn't mention that you did.
    I have had datatables that didn't update only to find I didn't do dataTable1Model.execute();
    Regards
    Jonathan

  • Sql command not working with date time??

    I am using my own sql query to fetch data in the sql command.
    Due to the problem I found - here is the basic example:
    The sql is:
    select to_number(to_date('10/11/2011 10:23:00','dd/mm/yyyy hh24:mi:ss') - to_date('10/11/2011 10:20:00','dd/mm/yyyy hh24:mi:ss'))  minu  from dual
    But I am not getting anything in Crystal Report tool!!
    In any sql tool I get results.
    When I am not using time part (hh24:mi:ss) :
    select to_number(to_date('10/11/2011','dd/mm/yyyy') - to_date('09/11/2011','dd/mm/yyyy'))  minu
    from dual
    I am getting data!!!!
    What is the problem??
    Initially I had it with parameters of type 'Date Time'
    Please, any one knows what the problem is?

    Hi,
    Sorry for the delay and thanks for answering.
    It was partial solution
    Moving to oracle driver, not (OLE DB), this specific one worked fine:
    select to_number(to_date('10/11/2011 10:23:00','dd/mm/yyyy hh24:mi:ss') - to_date('10/11/2011 10:20:00','dd/mm/yyyy hh24:mi:ss'))*100 minu from dual
    BUT
    When I tried to change one of the hardcoded values to be parameter of type 'Date Time' I couldn't pass the validation step - mostly the errors:
    "ORA 00900 Invalid sql statment"   and
    "ORA - 00907: Missing right parnthesis"
    No matter which format I used.
    Last version is:  
    select to_date('{?tsStartReport}','yyyy-mm-dd hh24:mi:ss') from dual
    Any idea why 'Date Time; is so problematic? How can I workaround it?

  • SQL Command conversion in abap code

    Hi,
    I want to implement the UNION, INTERSECT and MINUS SQL commands in abap code. Please give me the appropriate solutions asap.
    For Example:
    select field1, field2, . field_n
    from tables
    <b>UNION</b>
    select field1, field2, . field_n
    from tables;
    select field1, field2, . field_n
    from tables
    <b>MINUS</b>
    select field1, field2, . field_n
    from tables;
    select field1, field2, . field_n
    from tables
    <b>INTERSECT</b>
    select field1, field2, . field_n
    from tables;
    Thanks,
    Ravi

    Hi Ravi
    Check out this procedure...
    DATA: FRANKFURT(4) TYPE X,
          FRISCO(4)    TYPE X,
          INTERSECT(4) TYPE X,
          UNION(4)     TYPE X,
          BIT          TYPE I.
    DATA: CARRID TYPE SPFLI-CARRID,
          CARRIER LIKE SORTED TABLE OF CARRID
                              WITH UNIQUE KEY TABLE LINE.
    DATA WA TYPE SPFLI.
    SELECT CARRID FROM SCARR INTO TABLE CARRIER.
    SELECT CARRID CITYFROM FROM SPFLI
                           INTO CORRESPONDING FIELDS OF WA.
      WRITE: / WA-CARRID, WA-CITYFROM.
      READ TABLE CARRIER FROM WA-CARRID TRANSPORTING NO FIELDS.
      CASE WA-CITYFROM.
        WHEN 'FRANKFURT'.
          SET BIT SY-TABIX OF FRANKFURT.
        WHEN 'SAN FRANCISCO'.
          SET BIT SY-TABIX OF FRISCO.
      ENDCASE.
    ENDSELECT.
    INTERSECT = FRANKFURT BIT-AND FRISCO.
    UNION     = FRANKFURT BIT-OR  FRISCO.
    SKIP.
    WRITE 'Airlines flying from Frankfurt and San Francisco:'.
    DO 32 TIMES.
      GET BIT SY-INDEX OF INTERSECT INTO BIT.
        IF BIT = 1.
          READ TABLE CARRIER INDEX SY-INDEX INTO CARRID.
          WRITE CARRID.
        ENDIF.
    ENDDO.
    SKIP.
    WRITE 'Airlines flying from Frankfurt or San Francisco:'.
    DO 32 TIMES.
      GET BIT SY-INDEX OF UNION INTO BIT.
        IF BIT = 1.
          READ TABLE CARRIER INDEX SY-INDEX INTO CARRID.
          WRITE CARRID.
        ENDIF.
    ENDDO.
    This produces the following output list:
    The program uses four hexadecimal fields with length 4 - FRANKFURT, FRISCO, INTERSECT, and UNION. Each of these fields can represent a set of up to 32 elements. The basic set is the set of all airlines from database table SCARR. Each bit of the corresponding bit sequences representes one airline. To provide an index, the external index table CARRIER is created and filled with the airline codes from table SCARR. It is then possible to identify an airline using the internal index of table CARRIER.
    In the SELECT loop for database table SPFLI, the corresponding bit for the airline is set either in the FRANKFURT field or the FRISCO field, depending on the departure city. The line number SY-TABIX is determined using a READ statement in which no fields are transported.
    The intersection and union of FRANKFURT and FRISCO are constructed using the bit operations BIT-AND and BIT-OR.
    The bits in INTERSECT and UNION are read one by one and evaluated in two DO loops. For each position in the fields with the value 1, a READ statement retrieves the airline code from the table CARRIER.
    Comparing Bit Sequences
    Use the following three operators to compare the bit sequence of the first operand with that of the second:
    <operator>
    Meaning
    O
    bits are one
    Z
    bits are zero
    M
    bits are mixed
    The second operand must have type X. The comparison takes place over the length of the second operand. The first operand is not converted to type X.
    The function of the operators is as follows:
    O (bits are one)
    The logical expression
    <f> O <hex>
    is true if the bit positions that are 1 in <hex>, are also 1 in <f>. In terms of set operations with bit sequences, this comparison is the same as finding out whether the set represented by <hex> is a subset of that represented by <f>.
    Z (bits are zero)
    The logical expression
    <f> Z <hex>
    is true if the bit positions that are 1 in <hex>, are 0 in <f>.
    M (bits are mixed)
    The logical expression
    <f> M <hex>
    is true if from the bit positions that are 1 in <hex>, at least one is 1 and one is 0 in <f>.
    Caution: The following programs are no longer supported in Unicode systems:
    REPORT demo_log_expr_bits .
    DATA: text(1) TYPE c VALUE 'C',
          hex(1) TYPE x,
          i TYPE i.
    hex = 0.
    DO 256 TIMES.
      i = hex.
      IF text O hex.
        WRITE: / hex, i.
      ENDIF.
      hex = hex + 1.
    ENDDO.
    The output is as follows:
    00          0
    01          1
    02          2
    03          3
    40         64
    41         65
    42         66
    43         67
    Here, the bit structure of the character 'C' is compared to all hexadecimal numbers HEX between '00' and 'FF' (255 in the decimal system), using the operator O. The decimal value of HEX is determined by using the automatic type conversion during the assignment of HEX to I. If the comparison is true, the hexadecimal number and its decimal value are displayed on the screen. The following table shows the bit sequences of the numbers:
    Thanks
    Ashok

  • Read from sql task and send to data flow task - [OLE DB Source [1]] Error: A rowset based on the SQL command was not returned by the OLE DB provider.

    I have created a execut sql task -
    In that, i have a created a 'empidvar' variable of string type and put sqlstatement = 'select distinct empid from emp'
    Resultset=resultname=0 and variablename=empidvar
    I have added data flow task of ole db type and I put this sql statement under sql command - exec emp_sp @empidvar=?
    I am getting an error.
    [OLE DB Source [1]] Error: A rowset based on the SQL command was not returned by the OLE DB provider.
    [SSIS.Pipeline] Error: component "OLE DB Source" (1) failed the pre-execute phase and returned error code 0xC02092B4.

    shouldnt setting be Result
    Set=Full Resultset as your query returns a resultset? also i think variable to be mapped should be of object type.
    Then for data flow task also you need to put it inside a ForEachLoop based on ADO.NET recordset and map your earlier variable inside it so as to iterate for every value the sql task returns.
    Also if using SP in oledb source make sure you read this
    http://consultingblogs.emc.com/jamiethomson/archive/2006/12/20/SSIS_3A00_-Using-stored-procedures-inside-an-OLE-DB-Source-component.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to find out the failed sql command and its data from DEFERROR

    Hi,
    has anybody a procedure or some other possibilities to read the content of column USER_DATA of the advanced replication view DEFERROR in order to find out the failed sql command and its column values?
    Thanks in advance.

    Hi Vishwa,
                 The control would be something like this for navigation in Get_p_xxx method u mention as link and u mention a event name which gets triggered on the click of this hyperlink. So your GET_P_XXX method would have the following code:
    CASE iv_property.
        WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
          rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
        WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
          rv_value = 'EXAMPLE'.
    Now you have to create a method as EH_ONEXAMPLE at your IMPL class and within which you would give an outbound plug method. Within the outbound plug the target data would be filled in the collection and window outbound plug would be triggered.
    This is a huge topic and  i have just mentioned you basic things.
    Regards,
    Bharathy.

  • Read data from SharePoint using ABAP sql command

    We need to read data from a SharePoint site and update the sap object services with the information. There is a lot of information on how to put data into Sharepoint from SAP, but we need to get data from SharePoint and put it into SAP. Is it possible to retrieve data from SharePoint using sql command in ABAP program? If it is possible, what do we need to do to have SAP recognize where to get the SharePoint data?
    Richard Newman

    Hi Newman,
    You can use native sql in your abap code to read data from SharePoint's database. But I would suggest you to generate a SharePoint webservice which can provide you the neccessary data so that you can consume this webservice in ABAP
    (Will be quite faster than native sql).
    Regards,
    Ozcan.

  • Converting a SQL Command Parameter from Date to Char

    Hi,
    I'm using CR XI version 11.0.0.1282.  I've created a report using a SQL Command and have a parameter defined as Date.  I need to convert this Date parameter to a CHAR and have created my WHERE clause as:
    WHERE  "CC_PAYH"."PPOST"= CHAR ('{?From Date}') AND
    "CC_PAYH"."PPTYPE"<>13
    I get a message saying 2008 is not a valid token which in AS400 means it doesn't like the year.  Go figure. 
    I've tried running a similar query in AS400 and I get the desired affect.  I've tried removing the parameter from the Where clause and putting it into the Select like:
    CHAR ('{?From Date}') as MyTestDate
    just to see the representation I would get and I get the same error. 
    The question I have like everyone else is; is this possible with this version of Crystal?  I assume so since the same query will work in the database itself. 
    Thanks,
    Brian

    Hi Brain,
        Can you please try the query similar to the following syntax and verify whether it helps you!
    Select * from Orders where ([Order Date]) =
    CStr({?Date})
    Regards,
    Vinay

  • Cannot change SQL command text in Data Flow Task

    I have an SSIS package that extracts data from Teradata into a SQL Server DB.
    I'm using SQL Server 2008 R2 EE x64, and Visual Studio 2008 PE (BIDS) supplied with it, accessing Teradata v13.
    In the Integration Services project, I have a Data Flow Task, it has an ADO .net source which has Data access mode set to “SQL Command”.
    This worked for a while when I initially entered a SQL statement to select data.
    But, when I change the existing SQL Command text and save the package, the changes are lost.
    It keeps going back to the original SQL Statement.
    It is currently “select col1, col2, … col10 from view1”.
    When I change it to anything else, like “select col5 from view1”, and save, and then double click the ADO NET source again, I find that the SQL command text is still the old one. It goes back to the previous statement.
    I’ve tried other statements like “exec macro” for Teradata, etc. but the same thing keeps happening - changes are not saved.
    Does anyone have any ideas on this, or have you seen this before?

    This is odd, but seems to be a component metadata corruption; so why don't you:
    delete the teradata connector and source component, then re add them back, see if it now accepts the new SQL statement, if this does not work
    abandon this package and create a new one replicating the functionality incorporating the new SQL.
    In case #1 and 2 both fail post here any errors observed and find out whether you are missing any updates to either Teradata provider or SQL Server
    Arthur My Blog

  • Execute SQL Task - UPDATE or Data Flow Data Conversion

    Good Morning folks,
    I want to know which is more fast to convert data type.
    I want to convert nvarchar(255) to datetime2,
    using t-sql (execute sql task)
    UPDATE TBL
    SET  FIELD1= CAST(FIELD1AS DATETIME2)
    GO
    or data conversion(data flow)
    Thank..

    Itz Shailesh, my t-sql have only UPDATE, not many UPDATES... so it's one batch, no 2,3,4... So.. it's Only one update.. ex: update table set field1 = cast(field1 as datetime2), field2 = cast(field2 as datetime2). not : update table set field = cast(field
    as datetime2) go    update table set field2 = cast(field2 as datetime2) go.... understand?
    Yeah, I understand that you have to update just 1 field. What I am saying, if you have to update millions of rows then you must update rows in batches ( lets say batch of 50k). This way you will only touch 50k rows at a time and not all rows from table.
    I see that your rows are less however I would still prefer the option of data conversion transformation over update statement.
    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

  • How to replace data in sql command

    Hi all
    if i had one column data like
    http://localhost:123
    http://localhost:123 a
    http://localhost:123 bg
    http://localhost:123 fdasf
    does any sql command line or method i can use to relace this column data?
    the relace it should be like
    http://127.0.0.1:123
    http://127.0.0.1:123 a
    http://127.0.0.1:123 bg
    http://127.0.0.1:123 fdasf
    regard

    Hi all
    if i had one column data like
    COL1 COL2
    http://localhost:123
    http://localhost:123 a
    http://localhost:123 bg
    http://localhost:123 fdasf
    does any sql command line or method i can use to
    relace this column data?
    the relace it should be like
    COL1 COL2
    http://127.0.0.1:123
    http://127.0.0.1:123 a
    http://127.0.0.1:123 bg
    http://127.0.0.1:123 fdasf
    regardselect replace(col1,'localhost','127.0.0.1') column1, col2 from table;
    Good Luck

  • SQL command to get latest effective date

    Hi!
    How can i want to write a sql command to fetch records as such
    Vendor;    Item;     EffectiveDate;    UnitPrice;    Remarks
    Vend1;      ABC;    31/01/2012;        120;            Dont show
    Vend1;      ABC;    29/02/2012;        150;            Show
    Vend2;      ABC;    01/01/2012;        140;            Show
    Vend1;      XYZ;    15/01/2012;        100;            Show
    Please help me, so far I can only figuire out how to get the latest effective date by vendor and item but was not able to get UnitPrice
    SELECT  "VendPart"."Vendor", "VendPart"."Item", Max("VendPart"."EffectiveDate") AS MaxOfEffectiveDate
    FROM   "POS_LiveRpt"."dbo"."VendPart" "VendPart"
    GROUp BY "VendPart"."Vendor", "VendPart"."Item"
    Edited by: MichellePoh on Feb 23, 2012 9:58 AM

    hi Michelle,
    you can use a subquery in your command to bring back the UnitPrice that is applicable to the max date...see the code below for an idea.
    you'll have to change the "UnitPrice" field below to match yours.
    note that in the subquery the vendpart table has been aliased as vendpart2 for the subquery to work. also note that the code may not work in your database as Alan aluded to the fact that the syntax is specific to the database type...if you get any database errors please refer to your database manual or a forum for your database type that has a subquery. and of course there may be errors from my typing in the query as it's just being done inside this forum thread...but hopefully this will give you an idea how to do this.
    cheers,
    jamie
    SELECT 
    "VendPart"."Vendor",
    "VendPart"."Item",
    Max("VendPart"."EffectiveDate") AS MaxOfEffectiveDate,
    SELECT "VendPart2"."UnitPrice"
    FROM "POS_LiveRpt"."dbo"."VendPart" "VendPart2"
    WHERE "VendPart2"."EffectiveDate" = Max("VendPart"."EffectiveDate")
    AND  "VendPart2"."Vendor" =  "VendPart"."Vendor"
    AND "VendPart2"."Item" = "VendPart"."Item"
    ) AS UnitPrice
    FROM  
    "POS_LiveRpt"."dbo"."VendPart" "VendPart"
    GROUp BY
    "VendPart"."Vendor", "VendPart"."Item"

  • SQL Command to select MAX(date) & Max(time)

    My am having a really hard time getting a sql command to return data with the max(date) & max(time) combination. I think I need a sub query but can not figure it out. I have looked all over the internet but still don't understand it. Below is my command which returns the max date & max time but they are not from the same row of data. Please help.
    SELECT  "labor"."order-no", "labor"."oper-no", MAX("labor"."end-date") AS myDate, Max("labor"."end-time") AS myTime
    FROM   "E940LIVE"."PUB"."tm-log" "labor"
    WHERE  "labor"."order-no"='73153-bc' AND "labor"."company"='01'
    GROUP BY  "labor"."order-no", "labor"."oper-no"

    Progress does not support the DATEADD function. Waht if I forget the number is time and look at it just as a number. Here is my data and what I have tried (again I don't understand the multiple select concept yet).
    Data
    oper-no   end-date    end-time
      20      2/2/2010     41,975
      30      2/3/2010     45,906
      30      2/16/2010    32,941
      40      2/4/2010     46,099
      40      2/4/2010     50,227
      40      2/4/2010     59,466
      40      2/4/2010     62,024
      40      2/16/2010    43,838
      60      2/17/2010    32,679
      90      2/25/2010    35,270
    SQL Command
    SELECT a."oper-no", a."end-time", a."end-date"
    FROM   "E940LIVE"."PUB"."tm-log" a, (SELECT "end-time", max("end-date") AS max_date FROM "E940LIVE"."PUB"."tm-log" WHERE  "order-no"='73153-bc' AND "company"='01' GROUP BY "end-date", "end-time") b
    WHERE  a."end-time" = b."end-time" AND a."end-date" = b.max_date AND a."order-no"='73153-bc' AND a."company"='01'
    Result
    oper-no   end-date     end-time
      20      2/2/2010      41,975
      30      2/3/2010      45,906
      40      2/4/2010      50,227
      40      2/4/2010      46,099
      40      2/4/2010      59,466
      40      2/4/2010      62,024
      30      2/16/2010     32,941
      40      2/16/2010     43,838
      60      2/17/2010     32,679
      90      2/25/2010     35,270
    Desired Result
    oper-no   end-date    end-time
      20      2/2/2010     41,975
      30      2/16/2010    32,941
      40      2/16/2010    43,838
      60      2/17/2010    32,679
      90      2/25/2010    35,270
    Thanks for any and all help!
    Wayne

Maybe you are looking for