URGENT How to map an aggregated result to Target flat-file?**

All,
I am trying to map the result of the following query from 'source1' to my target which is a flat file.
The query result set has 'one row per account' which is unique and record looks like :
12300,9675,2008,6,11250,$-2095.48
Questions>>>
1. what is the proper context ( at what level-- project, global?) should I create the $v_year, $v_period variables.?
I need the values for this 2 variables to be recognized at the end once I 'package' the mapping
so user can pass on the values at runtime.
2. Can this query somehow to be plugged as a 'filter' on top of the 'source1' in the interface? and result then mapped to the target?
what is the alternative if not? (dump it to another temp table? in SUNOPSIS memory engine?)
SELECT
PS_.product,
PS_.operating_unit,
$V_YEAR,
$V_PERIOD,
PS_.account,
SUM(PS_.posted_total_amt) TOT_AMT
FROM psoftdb.ps_ledger PS_
WHERE
((PS_.ledger='ACTUALS')
AND (PS_.accounting_period <=$V_PERIOD)
AND (PS_.fiscal_year=$V_YEAR)
AND ((SUBSTR(PS_.account,1,1)='1' OR
SUBSTR(PS_.account,1,1)='2' OR
SUBSTR(PS_.account,1,1)='3')
GROUP BY
PS_.product,
PS_.operating_unit,
PS_.account

IN order to do this you will need to declare two variables - at project level, with non-persistent type. You will need to have reverse engineered the source table into a data model. You should also define your flat file as a data model too. If this does not already exist, you will need to manually define it.
Create a package in which the first steps are to declare the variables.
then insert an interface which uses your source table as a source and your flat file as a target.
In the interface select "Staging area different from target" and select the schema of your source from the drop-down.
In your source, drag all the columns on which you want to filter (including accounting_period and fiscal_year) on to the grey background and fill in the filter details. Use the expression editor to set the filter, selecting the variable from the list, which ensures the correct syntax is used.
Fill in all the other mapping details.
On the flow tab select the IKM SQL to File Append as your IKM. This should allow you to create your output in one step.
Build a scenario from your package, and when you execute it pass in the variables:
e.g. startscen MYSCEN MYCONTEXT 001 "-MYPROJ.V_YEAR=1999" "-MYPROJ.V_PERIOD=07"

Similar Messages

  • How to output a query results into a text file

    How to output a query results into a text file instead of outputing it to the screen..
    is there a way for us to write a SQL query which specifies to output the query results to a text file.
    Pls let me know how to do it
    Thanking u in advance
    regards
    Muraly

    Muraly,
    If you are using SQL*Plus 8.1.6 or later, you can also spool output to a file in HTML format, eg
    SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
    SPOOL c:\temp\report.html
    SELECT DEPARTMENT_NAME, CITY
    FROM EMP_DETAILS_VIEW
    WHERE SALARY>12000;
    SPOOL OFF
    SET MARKUP HTML ENTMAP OFF
    In iSQL*Plus 9.0.1 (the browser-based interface to SQL*Plus) onwards, you can also send the HTML output to a new web browser window, or an html file -- much easier than the command line method.
    Alison

  • How we will change the lowercase data in flat file to uppercase

    How can i change the lowercase date in flat file  after uploaded, out put should be uppercase.

    Hi ramana,
    See the example.
    DO.
       READ DATASET s_filename INTO I_TEMP.
       IF SY-SUBRC <> 0.
        EXIT.
       ELSE.
         move I_TEMP to I_FINALTAB.
         append I_FINALTAB.
         clear I_FINALTAB.
      ENDIF.
    ENDDO.
         In the above code we are moving the data form file to i_temp and i_temp to I_FINAL.
    Here before moving to i_FINAL.
    use  TRANSLATE i_temp to UPPSERCASE.
    Then move to i_final.
    Pls. reward if useful.

  • Automate a report execution & save results as a flat file on FTP server

    Hello Gurus
    I am working on BW 3.5 version. I want to Automate a report execution, and save the results of the same as a flat file on a FTP server.---- (So that another program could look it up and run few processes at it's end). pls give me solution in step-by-step format. Plss help.....

    Hi Priyadarshini,
    You can Automate a Report Execution and Save the results as a flat file by creating a Query Extract and by scheduling  the Query Extractor using the T-Code RSCRM_BAPI.
    Steps:
    1. Goto RSCRM_BAPI T-Code
    2. Select the Quey from the list
    3. Click on Query Extract
    4. Create a Query Extractor and give the file name and Path.
    5. Schedule the Query Extractor.
    Hope it helps.
    Regards,
    -Vijay

  • How to extract data From Hyperion Essbase to Flat Files

    Hi ,
    Can anyone tell me how to extract data from Hyperion essbase to Flat file(e.g. .csv , .txt ,...) or Oracle Table using ODI.
    Regards,
    Avneet

    Hi sutirtha,
    I have make one column as key column now i am getting this error,
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 1, in ?
    com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.ODIEssbaseDataReader.getAppData(Unknown Source)
    at com.hyperion.odi.essbase.AbstractEssbaseReader.extract(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
    at org.python.core.PyMethod.__call__(PyMethod.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at org.python.core.PyInstance.invoke(PyInstance.java)
    at org.python.pycode._pyx7.f$0(<string>:1)
    at org.python.pycode._pyx7.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyCode.call(PyCode.java)
    at org.python.core.Py.runCode(Py.java)
    at org.python.core.Py.exec(Py.java)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:144)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)
    Caused by: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.validateColumns(Unknown Source)
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.init(Unknown Source)
    ... 33 more
    com.hyperion.odi.essbase.ODIEssbaseException: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)

  • How to get only aggregated results in a report?

    Hi,
    My report data comes in a completely drilled down format. My requirement is to only get the aggregated results in the report. The report has data for day,week and months. using the remove drill down option from the webviews the user can remove the days column to get the aggregated results for a week and same for a month. but my requirement is to show the user the aggregated results for a month.

    Hi,
    Give me your query design. And add some notes to that.

  • How to map a deep xml structure to flat structure

    Hi, I'm trying to map a deep xml structure to a flat file structure. See this:
    <SalesPoint>
             <header>
                  <idTx></idTx>
                  <opCode></opCode>
             </header>
             <body>
              <DataSet>
                   <codOperacion></codOperacion>
                   <codCanalDeVenta></codCanalDeVenta>
                   <cuitDeposito>
                   <docMinorista>
                   <fechaOperacion>
                   <codCC>
                   <Details>
                         <Dato>
                                        <nroSerieEquipo></nroSerieEquipo>
                            <codNMU></codNMU>
                            <codOrigenEquipo></codOrigenEquipo>
                            <codConcepto></codConcepto>
                             <codSegmento></codSegmento>
                            <motivoSiniestro></motivoSiniestro>
                         </Dato>
                   </Details>
              </DataSet>
             </body>
    </SalesPoint>
    to:
    <SalesPoint>
            <idTx></idTx>
            <opCode></opCode>
         <codOperacion></codOperacion>
         <codCanalDeVenta></codCanalDeVenta>
         <cuitDeposito></cuitDeposito>
         <docMinorista></docMinorista>
         <fechaOperacion></fechaOperacion>
         <codCC></codCC>
            <nroSerieEquipo></nroSerieEquipo>
            <codNMU></codNMU>
         <codOrigenEquipo></codOrigenEquipo>
         <codConcepto></codConcepto>
         <codSegmento></codSegmento>
         <motivoSiniestro></motivoSiniestro>
    </SalesPoint>
    Thanks in advance!!!!

    I do not think this is a complex XML structure. All that you need to take care is about the contexts. How ever it is not possible to give u the complete mapping here. If you have tried mapping already and facing some issues.. please put it here.. so that some one can help you.
    VJ

  • How to create a target flat file in a mapping?

    Hi,
    I defined a Target location tar_loc (D:\target), a file modul and a file with location tar_loc and file name target_file.
    In a mapping I try to use this file as a target.
    After validating I get the message: VLD-2357: The name of the target file for target_file is missing.
    What to do?
    Thanks
    Andreas

    Hi Andreas
    Set the target data file name when you configure the mapping on the file ooperator, see;
    http://blogs.oracle.com/warehousebuilder/2007/06/some_tips_and_hints_about_xml.html
    Also this one is interesting for dynamic file names;
    http://blogs.oracle.com/warehousebuilder/2007/07/dynamically_generating_target.html
    Cheers
    David

  • How to add process model results to the sequence file results?

    After my sequence file runs, I would like to add some additional results using the process model. I need to log my equipment list which is obtained by the process model. Alternatively, I could add a sub-sequence to the end of each of my sequence files for doing this, but that would create maintenance problems if I ever needed to change the way equipment is logged. Does anyone know a way to (1) append process model results to the sequence file results or (2) force each client sequence file to call a sub-sequence before returning to the process model.

    Mark -
    The report and database process model routines expect a single subsequence step result that invoked MainSequence. This result contains the results from the sequence call.
    In TestStand after the process model root sequence call to MainSequence is performed, the property Locals.ResultList[0] is the MainSequence result. The subproperty Locals.ResultList[0].TS.SequenceCall.ResultList contains the results from the steps in MainSequence.
    One option is to create a subsequence call in the process model that logs the equipment info in the results for its steps. The call to the subsequence should not be checked to record results.
    This subsequence would have a parameter called ResultList. The Result type does not exist in the Insert menu, so you can only create the parameter by copying the empty Locals.ResultList and pasting it in the parameters. Then change its type from By Value to By Reference.
    In the setup of the subsequence, add the following steps which do not record results. These steps rename the Locals.ResultList parameter to ResultListOrig, and then create a new Locals.ResultList alias property that really references Parameters.ResultList. This way any additions to the Locals.ResultList really append to the Parameter.ResultList.
    Setup
    Step: "Rename Locals.ResultList"
    StepType, Adapter: Action, Active-X
    Description:
    Action, Set PropertyObject.Name = "ResultListORIG"
    Record Results: False
    Step: "Create Alias in Locals"
    StepType, Adapter: Actioin, Active-X
    Description:
    Action, Call PropertyObject.SetPropertyObject ("ResultList",
    0x201 ' Not Owning and Create, Parameters.ResultList)
    Record Results: False
    In the Main steps, you add your equipment info steps which record results.
    In the Cleanup steps you undo the steps performed in Setup.
    Cleanup
    Step: "Delete Alias in Locals"
    StepType, Adapter: Action, Active-X
    Description:
    Action, Call PropertyObject.DeleteSubProperty ("ResultList",
    0x400 ' Refer to Alias)
    Record Results: False
    Step: "Rename Locals.ResultListORIG"
    StepType, Adapter: Action, Active-X
    Description:
    Action, Set PropertyObject.Name = "ResultList"
    Record Results: False
    I have attached a TS 2.0 version of SequentialModel.Seq that has a AppendResults subsequence in it and this is invoked after MainSequence in Single Pass entry point.
    Hope this helps...
    Scott Richardson (NI)
    Scott Richardson
    National Instruments
    Attachments:
    SequentialModel.Seq ‏174 KB

  • Mapping Quantity keyfigure in BI 7- Flat file datasource

    Hi Guys,
    I have a problem in creating transformations for Quantity key figure for flat file datasource. In my csv file quantity is just  a number. i created a datasource and Infopackage and loaded data into PSA without any problem.
    In cube i have quantity key figure of QUAN type with 0UNIT unit of measure. So when I try to map Quantity in datasource with quantity InfoObject, 0UNIT is empty.  So I am unable to activate transformations.
    Can somebody suggest me how to proceed with htis problem? Should I define Quantity key figure as just number?
    Thank you in advance

    Hi Sneralla,
      you can take one  more field on you flatfile.. as units(ex: KG  or CM.. like that) beside of the  quanity filed..  and now load it into PSA and  now create transformations...  and now map this  units filed to  newly added field...
       you can try this option.. becasue.. when you are loading  Quantity   field data  from flat file means we need to mention the units also..
    regards
    @jay

  • Cube like aggregation behavior from a flat file data source

    Is the following workflow possible in Xcelsius and if so how would your organize you logic to be able to acheive this?  Any examples would greatly be appreciated
    My data source is XML, therefore a flat file.
    The flat file contains multiple dimensions for which the customer wants to aggregate by based on the selection and also include and "ALL" option for every dimension/selector.
    Essentially, the file is structured like this:
    ie: Dim1  Dim 2  Dim3   Dim 4   Dim5  Metric1    Metric2
           a        c         e          j          l          5             5
           a        c         e          j          m        3             2
           a        c         e          j          n         4             8
           a        c         e         k          o         3             4
           a        c         e         k          n         8             2
            ...etc         
    We need drop down selectors for Dim1-Dim4 with the "ALL" option.  I would have my tables and charts etc use the Dim5, Metric1 and Metric2. 
    I've used the "Lookup" function to create 1 level of aggregation in a flat file structure with 1 dimension, such as the "Lookup" would call all the Dim1entries and insert into a group of referenced cells and then i would use the "Sum" function from Excel.
    But is this possible with multiple dimensions and include the "ALL" option.  If so, how?  The workflow defined is ideal for a CUBE architecture but for many different political reasons we need to be able to address this with Xcelsius being sourced from a flat file ie XML.  Any insight would be greatly appreciated..

    hi there.
    if you backend is SAP BW connected via OLAP Universe you could use L0 Dimensions for all aggregation in WebI Layer. (Check the Blog's of Ingo Hilgefort for details)
    Best Regards
    Ulrich
    http://www.xcelsius-insight.com

  • Saving query results to a flat file

    Hello Experts!
    We have a very specific issue on our current project and I would like to know if any of you have ever done something similar. We are taking query results from BW (after complex calculations, some based on SY-DATE) and saving them to flat files to transfer to a SQL database structure on the Enterprise Portal. From here, the portal team renders the information into more "static" dashboards that include mouse over features and even limited drilldown (i.e. no matter where a user clicks the report always drills down on profit center)
    There are many reasons why the model is set up as such (mostly training of executive level end users), and even though it doesn't mesh with the idea that BW could do this work on its own, we have to work with what we have.
    We have come up with 3 possible ways to save this data to flat files and hopefully someone can tell us which might be the most effective.
    1.) Information Broadcasting. If we broadcast XML files to the portal, will the portals team be able to read that data into a SQL database? Is there another way to use broadcasting to create and send a flat file to specific location?
    2.) RSCRM_BAPI. This transaction seems to not support texts.
    3.) Open Hub. In order to get the open hub to work, we first have to save all of our query results to direct write data store objects using APD. (calculations based on current date, for example, would require daily full loads to the underlying data providers otherwise.)
    What is the best way to accomplish this? Is information broadcasting capable of doing this?
    Thanks!

    Hi Adam,
    Do you have to use flat files to load the information to a SQL database? (if so maybe someone else has a suggestion on which way would be the best).
    I try to stay away from flat file uploads as there is a lot of manual work involved. May I suggest setting up a connection to your SQL table in the DBCON table and then writing a small abap program to push data into the SQL database (which you can automate).
    1) Use APD to push data into a table within BW.
    2) Go to transaction SM30 > table DBCON and setup a new entry specifying the conncection parameters to your SQL database.
    3) In SE38 Write an ABAP program along the folloing lines (assuming the connection you set in DBCON is named conn1:
    data: con_name like dbcon-con_name
    con_name = 'conn1'.
    exec sql.
      set connection :con_name
    endexec.
    ****have a select statement which reads data from your table which the data is saved from the APD into an internal table**********
    ****loop on the internal table and have a SQL insert statement to insert the records into the SQL table as below******
    exec sql.
    insert into <SQL TABLE> (column names seperated by ,)
    values (column names of the internal table seperated by ,)  if the internal table is named itab the columns have to be specified as :itab-column1
    If you decide to take this approach you may find more info on DBCON and the process in sdn. Good Luck!
    endexec.

  • How to download an Internal Table to a flat file

    Hi All,
    I have an Internal Table with 7 columns.I am using FM 'Gui_download'.The flat file is generating correctly.But I need to display the 7 fields vertically one after other instead of displaying horizontally.The internal table consists of only one record.
    Very Urgent
    Thanks

    Hi,
    do you know the ABAP Development? I think you should post your question there. Also have you tried the SDN Search?
    Regards
    Gregor

  • How can I download from R/3 to flat file?

    Hi
    My requirement is to download Material and Supplier data from R/3 to flat file...
    These are the fields I have to bring it from SAP R/3 but I don not want to DOWNLOAD FM. I want to Concatenate from Internal Table and put it on application server.
    There are my following fields...
    Material and Supplier
       1. Selection criteria
             - Based on plant
             - Hubs and FSL/Hubs
             - Hubs can pull both Repair and NewBuy vendor
             - FSL/Hubs pull only Repair vendor
       2. Material – EORD-MATNR
       3. Region – Determined by 9* plants
       4. Site
             1. plant-(W) and plant-(C) for FSL/Hubs
             2. plant-(S) for DCs
       5. Supplier
             1. Menlo/Repair for DC
             2. Repair only for hub/fsl
       6. Supplier-type – PURCHASE or REPAIR
       7. Leadtime - (The number of days between placing an order and receiving an order)
       8. Order Horizon – “2”
       9. Minimum OQ – “3”
      10. Order cost – “50”
      11. Supplier part number – EORD-MATNR
    Waiting for some help and (or) sample code for this...
    Thanks in advance.

    Here is an example program showing how to write a tab-delimited file to the application server.  All you need to do is get all your data into an internal table, then loop at it, concatenate all fields into a string and then transfer that string.
    report zrich_0001.
    parameters: d1 type localfile default '/usr/sap/TST/SYS/Test.txt'.
    data: begin of itab occurs 0,
          field1(20) type c,
          field2(20) type c,
          field3(20) type c,
          end of itab.
    data: str type string.
    constants: con_tab type x value '09'.
    * if you have a newer version, then you can use this instead.
    *constants:
    *    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
    start-of-selection.
    itab-field1 = 'ABC'.
    itab-field2 = 'DEF'.
    itab-field3 = 'GHI'.
    append itab.
    itab-field1 = '123'.
    itab-field2 = '456'.
    itab-field3 = '789'.
    append itab.
      open dataset d1 for output in text mode.
      loop at itab.
        concatenate itab-field1 itab-field2 itab-field2 into str
                      separated by con_tab.
        transfer str to d1.
      endloop.
      close dataset d1.
    Regards,
    Rich Heilman

  • How to convert from SQL Server table to Flat file (txt file)

    I need To ask question how convert from SQL Server table to Flat file txt file

    Hi
    1. Import/Export wizened
    2. Bcp utility
    3. SSIS 
    1.Import/Export Wizard
    First and very manual technique is the import wizard.  This is great for ad-hoc and just to slam it in tasks.
    In SSMS right click the database you want to import into.  Scroll to Tasks and select Import Data…
    For the data source we want out zips.txt file.  Browse for it and select it.  You should notice the wizard tries to fill in the blanks for you.  One key thing here with this file I picked is there are “ “ qualifiers.  So we need to make
    sure we add “ into the text qualifier field.   The wizard will not do this for you.
    Go through the remaining pages to view everything.  No further changes should be needed though
    Hit next after checking the pages out and select your destination.  This in our case will be DBA.dbo.zips.
    Following the destination step, go into the edit mappings section to ensure we look good on the types and counts.
    Hit next and then finish.  Once completed you will see the count of rows transferred and the success or failure rate
    Import wizard completed and you have the data!
    bcp utility
    Method two is bcp with a format file http://msdn.microsoft.com/en-us/library/ms162802.aspx
    This is probably going to win for speed on most occasions but is limited to the formatting of the file being imported.  For this file it actually works well with a small format file to show the contents and mappings to SQL Server.
    To create a format file all we really need is the type and the count of columns for the most basic files.  In our case the qualifier makes it a bit difficult but there is a trick to ignoring them.  The trick is to basically throw a field into the
    format file that will reference it but basically ignore it in the import process.
    Given that our format file in this case would appear like this
    9.0
    9
    1 SQLCHAR 0 0 """ 0 dummy1 ""
    2 SQLCHAR 0 50 "","" 1 Field1 ""
    3 SQLCHAR 0 50 "","" 2 Field2 ""
    4 SQLCHAR 0 50 "","" 3 Field3 ""
    5 SQLCHAR 0 50 ""," 4 Field4 ""
    6 SQLCHAR 0 50 "," 5 Field5 ""
    7 SQLCHAR 0 50 "," 6 Field6 ""
    8 SQLCHAR 0 50 "," 7 Field7 ""
    9 SQLCHAR 0 50 "n" 8 Field8 ""
    The bcp call would be as follows
    C:Program FilesMicrosoft SQL Server90ToolsBinn>bcp DBA..zips in “C:zips.txt” -f “c:zip_format_file.txt” -S LKFW0133 -T
    Given a successful run you should see this in command prompt after executing the statement
    Starting copy...
    1000 rows sent to SQL Server. Total sent: 1000
    1000 rows sent to SQL Server. Total sent: 2000
    1000 rows sent to SQL Server. Total sent: 3000
    1000 rows sent to SQL Server. Total sent: 4000
    1000 rows sent to SQL Server. Total sent: 5000
    1000 rows sent to SQL Server. Total sent: 6000
    1000 rows sent to SQL Server. Total sent: 7000
    1000 rows sent to SQL Server. Total sent: 8000
    1000 rows sent to SQL Server. Total sent: 9000
    1000 rows sent to SQL Server. Total sent: 10000
    1000 rows sent to SQL Server. Total sent: 11000
    1000 rows sent to SQL Server. Total sent: 12000
    1000 rows sent to SQL Server. Total sent: 13000
    1000 rows sent to SQL Server. Total sent: 14000
    1000 rows sent to SQL Server. Total sent: 15000
    1000 rows sent to SQL Server. Total sent: 16000
    1000 rows sent to SQL Server. Total sent: 17000
    1000 rows sent to SQL Server. Total sent: 18000
    1000 rows sent to SQL Server. Total sent: 19000
    1000 rows sent to SQL Server. Total sent: 20000
    1000 rows sent to SQL Server. Total sent: 21000
    1000 rows sent to SQL Server. Total sent: 22000
    1000 rows sent to SQL Server. Total sent: 23000
    1000 rows sent to SQL Server. Total sent: 24000
    1000 rows sent to SQL Server. Total sent: 25000
    1000 rows sent to SQL Server. Total sent: 26000
    1000 rows sent to SQL Server. Total sent: 27000
    1000 rows sent to SQL Server. Total sent: 28000
    1000 rows sent to SQL Server. Total sent: 29000
    bcp import completed!
    BULK INSERT
    Next, we have BULK INSERT given the same format file from bcp
    CREATE TABLE zips (
    Col1 nvarchar(50),
    Col2 nvarchar(50),
    Col3 nvarchar(50),
    Col4 nvarchar(50),
    Col5 nvarchar(50),
    Col6 nvarchar(50),
    Col7 nvarchar(50),
    Col8 nvarchar(50)
    GO
    INSERT INTO zips
    SELECT *
    FROM OPENROWSET(BULK 'C:Documents and SettingstkruegerMy Documentsblogcenzuszipcodeszips.txt',
    FORMATFILE='C:Documents and SettingstkruegerMy Documentsblogzip_format_file.txt'
    ) as t1 ;
    GO
    That was simple enough given the work on the format file that we already did.  Bulk insert isn’t as fast as bcp but gives you some freedom from within TSQL and SSMS to add functionality to the import.
    SSIS
    Next is my favorite playground in SSIS
    We can do many methods in SSIS to get data from point A, to point B.  I’ll show you data flow task and the SSIS version of BULK INSERT
    First create a new integrated services project.
    Create a new flat file connection by right clicking the connection managers area.  This will be used in both methods
    Bulk insert
    You can use format file here as well which is beneficial to moving methods around.  This essentially is calling the same processes with format file usage.  Drag over a bulk insert task and double click it to go into the editor.
    Fill in the information starting with connection.  This will populate much as the wizard did.
    Example of format file usage
    Or specify your own details
    Execute this and again, we have some data
    Data Flow method
    Bring over a data flow task and double click it to go into the data flow tab.
    Bring over a flat file source and SQL Server destination.  Edit the flat file source to use the connection manager “The file” we already created.  Connect the two once they are there
    Double click the SQL Server Destination task to open the editor.  Enter in the connection manager information and select the table to import into.
    Go into the mappings and connect the dots per say
    Typical issue of type conversions is Unicode to non-unicode.
    We fix this with a Data conversion or explicit conversion in the editor.  Data conversion tasks are usually the route I take.  Drag over a data conversation task and place it between the connection from the flat file source to the SQL Server destination.
    New look in the mappings
    And after execution…
    SqlBulkCopy Method
    Sense we’re in the SSIS package we can use that awesome “script task” to show SlqBulkCopy.  Not only fast but also handy for those really “unique” file formats we receive so often
    Bring over a script task into the control flow
    Double click the task and go to the script page.  Click the Design script to open up the code behind
    Ref.
    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

Maybe you are looking for

  • How to change the default database charset to ISO8859-1?

    Hi all, I have created a table with a nvarchar field to store string, may i now how to change the default NLS charset to ISO88591 charset? Thanks in advance. chin.

  • Aperture - Transfer a photography folder and sub-folders to the library

    Hi All, Being a photographer, I recently jumped from my Dell XPS to the latest MacBook Pro and am still new on the use of Aperture. Working on PC before then, I used to work a lot on Adobe Bridge to organise my pictures. I now work with Aperture that

  • Multiple count(*)s in DML

    Hi, Is the following not possible? CREATE OR REPLACE VIEW oracle_counts AS SELECT count(de.name) AS Error_Count, count(dt.tablespace_name) AS Tablespace_Count FROM dba_errors de, dba_tablespaces dt; SQL> select * from oracle_counts; ERROR_COUNT TABLE

  • Redeploy BPM Biz Ops?

    Hi, is anyone dynamically redeploying code (EJB or otherwise) that implements BPM business operations without restarting the WLI server? I'm getting a worrisome stack trace the way that I did it (even though it seems to work, so far): As far as I cou

  • Autosaved as Unix Executable Files after editing font size?

    When I open a .txt file in TextEdit, and change the font, in the Finder I see a new Unix Executable File appear, with (Autosaved) after the file name. This is in addition to the original .txt file - so there are now 2 files of the same name showing.