Export data from a table to text file using srcipt task
Hi
i am new to SSIS
i have to export data from a table and append it into a existing file through SSIS script task
please help
Thanks
Umesh
Hi Umesh,
The data structure of the source table and the structure of the destination file are the same, right? Is the destination file a flat file? Do you have to do it through Script Task? If the destination file is a flat file, this can be done easily by using
the stock tasks/components other than .NET code. In the Data Flow Task, we choose the appropriate source adapter (such as OLE DB Source or ADO.NET Source) to extract data from the source table, perform transformation if necessary, and then load to the destination
file via a Flat File Destination. When setting up the Flat File Destination, uncheck the “Overwrite data in the file” option so that the extracted data will be appended to the existing file.
If you need to implement it through Script Task/Component indeed, you may benefit from the following code examples:
http://stackoverflow.com/questions/8070163/how-to-add-custom-footer-to-an-ssis-flat-file-seperate-component-or-script-tas
http://stackoverflow.com/questions/8467326/add-header-and-footer-row-flat-file-ssis
If you need further help about the script, I suggest that you ask a new question in .NET forums where you can get more dedicated support:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=netdevelopment
Regards,
Mike Yin
TechNet Community Support
Similar Messages
-
Upload data from Internal table to text file with '~' separator
can anyone help me to download data from internal table to flat file with '' separator. GUI_DOWNLOAD is not working in my case ....like for '' separator
Here it is
REPORT zkb_test1.
TYPE-POOLS: truxs.
DATA: i_scarr TYPE TABLE OF scarr,
i_conv_data TYPE truxs_t_text_data.
SELECT * FROM scarr INTO TABLE i_scarr.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = '~'
TABLES
i_tab_sap_data = i_scarr
CHANGING
i_tab_converted_data = i_conv_data
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = 'C:\Test1.txt'
filetype = 'ASC'
CHANGING
data_tab = i_conv_data
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards
Kathirvel -
how can i load data from a oracle table to a text file or CSV file using PL/SQL procedures where the pls/sql code will take the table name dynamically.........
soumenTry this thread..
Is it possible to export a pl/sql region as a csv file? -
[b]export data from a table to a csv or .txt file[/b]
hi plz i need help in how to export data from a table to a csv or .txt file
If you are using TOAD, then you can execute the statement like SELECT * FROM TABLE1
Then, you can go to Output Grid and you can say save as and you can save it as you want, excel, tab delimited or whatever.
Thanx,
Cheers, -
In PL-SQL archive data from a table to a file
I am currently developing a vb app where I need to archive data from a table to a file. I was hoping to do this with a stored procedure. I will also need to be able to retrieve the data from the file for future use if necessary. What file types are available? Thanks in advance for any suggestions.
What about exporting in an oracle binary format? The export files cannot be modifiable. Is there a way to use the export and import utility in PL/SQL?
null -
Download data from internal table to flat file.
I need to download the data from Internal table to Flat file. can any one suggest how to do it? i suppose WS_Download OR GUI_DOWNLOAD.
but if it is please guide me how to use this.
is thre any other F.M. please provide the information.
Thanks in advanceHi,
Try this,
* File download, uses older techniques but achieves a perfectly
* acceptable solution which also allows the user to append data to
* an existing file.
PARAMETERS: p_file like rlgrap-filename.
* Internal table to store export data
DATA: begin of it_excelfile occurs 0,
row(500) type c,
end of it_excelfile.
DATA: rc TYPE sy-ucomm,
ld_answer TYPE c.
CALL FUNCTION 'WS_QUERY'
EXPORTING
query = 'FE' "File Exist?
filename = p_file
IMPORTING
return = rc.
IF rc NE 0. "If File alread exists
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
text_question = 'File Already exists!!'
text_button_1 = 'Replace'
* ICON_BUTTON_1 = ' '
text_button_2 = 'New name'
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
IMPORTING
answer = ld_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
* Option 1: Overwrite
IF ld_answer EQ '1'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = p_file "File Name
filetype = 'ASC'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = it_excelfile "Data table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i003(zp) WITH
'There was an error during Excel file creation'(200).
exit. "Causes short dump if removed and excel document was open
ENDIF.
* Option 2: New name.
ELSEIF ld_answer EQ '2'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = p_file "File name
filetype = 'ASC' "File type
* col_select = 'X' "COL_SELECT
* col_selectmask = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
* "COL_SELECTMASK
filetype_no_show = 'X' "Show file type selection?
* IMPORTING
* act_filename = filename_dat
TABLES
data_tab = it_excelfile "Data table
* fieldnames =
EXCEPTIONS
file_open_error = 01
file_write_error = 02
invalid_filesize = 03
invalid_table_width = 04
invalid_type = 05
no_batch = 06
unknown_error = 07.
ENDIF.
ELSE. "File does not alread exist.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = p_file "File name
filetype = 'ASC' "File type
* IMPORTING
* FILELENGTH =
TABLES
data_tab = it_excelfile "Data table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i003(zp) WITH
'There was an error during Excel file creation'(200).
exit. "Causes short dump if removed and excel document was open
ENDIF.
ENDIF.
Regards,
Raghav -
Convert data from internal table to XML file.
Hi All,
I am selecting data from database into one internal table.
Now I want to convert data from internal table to xml file format and save in to my desktop. Please suggest me how I can achieve my requirement.
Kindly reply me ASAP.Use this FM. SAP_CONVERT_TO_XML_FORMAT
Check this link too -
Re: Data Export in XML format
XML files from ABAP programs -
How to Export data from a Table to Excel using PL/SQL Code
Hi,
I need to export data from a table to the excel sheet using PL/SQL script.
could you pls provide with custom codes or sample procedures.
Bobbyhttp://asktom.oracle.com/pls/ask/f?p=4950:8:7947129213057862756::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:728625409049
-
Downloading data from internal table to xls file leading zeros are not disp
Hai abap gurus,
when i am downloading data from internal table to excle file. some field values in a column are with leading zeros and some others dont have leading zeros.but in the output it is showing without leading zeros. then how to get with exact values.
Ex:
<b>ECC Code.</b>
045234
88567
098456
but output is giving like this:
45234
88567
98456
how to get the actual values.....
plz help me in this matter.Dear Kiran,
Those field in the internal table having Leading Zeroes, make those fields' datatype as character.
Then use the function module to download the content of the internal table to the excel file.
Regards,
Abir
Don't forget to Reward Points * -
How can i extract data from oracle table to flat file or excel spread shee
Hello,
DB Version is 10.1.0.3.0
How can i extract data from oracle table to flat file or excel spread sheet by using sub programs?
Regards,
DHere what I did
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
Sql> SPOOL bing
select * from -------;
SPOOL OFF;
I do not see file.
I also tried
Sql> SPOOL /tmp/bing
select * from -------;
SPOOL OFF;
But still not seeing the fie, -
Exporting data from database tables to a XML file
Hi,
We want to export data from Oracle database tables to an XML
file. What tool can we use for this purpose, and how do we go
about it ?
Can we extract data only from an Oracle8 database, or can we
extract data from Oracle7.3 databases too ?
Any help in this regard would be appreciated.
Thanks
Dipanjan
nullDipanjan (guest) wrote:
: Hi,
: We want to export data from Oracle database tables to an XML
: file. What tool can we use for this purpose, and how do we go
: about it ?
: Can we extract data only from an Oracle8 database, or can we
: extract data from Oracle7.3 databases too ?
: Any help in this regard would be appreciated.
: Thanks
: Dipanjan
Start by downloading the XML SQL Utility and make sure you have
the approriate JDBC 1.1 drivers installed for your database.
There are samples which will get you going included in the
archive.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
Manual Exporting of BLOB specific table to text file
Hi,
Our application is having 60000 record in a BLOB specific table.
My requirement is to export the entire table data to text files .
When I tried converting BLOB to sting and writing to file, it took almost 3 mins for 100 records, if so, will take so much of time in exporting data from BLOB specific table.
I am using the following logic,
byte[] bdata = blob.getBytes(1, (int)blob.length());
String data1 = new String(bdata);
buffer.append(data1);
Can anyone please tell me how can I speed up the operation.>
Our application is having 60000 record in a BLOB specific table.
My requirement is to export the entire table data to text files .
>
Welcome to the forum!
If you are looking for a pure Java solution you should post this question in the JDBC forum.
https://forums.oracle.com/forums/category.jspa?categoryID=288
Unless your BLOB data is located inline you are going to use Oracle to read 60,000 files, one at a time, and then use Java to write 60,000 files one at a time.
That will be a very slow process.
Also - your Java code is only going to read the LOB locator and inline BLOB data since you are not getting and processing the actual stream.
See 'Reading and Writing BLOB, CLOB and NCLOB Data' in the JDBC Dev Guide for details
http://docs.oracle.com/cd/B28359_01/java.111/b31224/oralob.htm#sthref756 -
How to copy datas from a table to a file.
Hi,
Can Someone help me how to do this using queries or procedures.
I want to copy the datas from the table to a flat file (eg. text or excel).
example:
CREATE TABLE emp
(FCST_DATE DATE,
LEVEL1 VARCHAR2(2000) ,
Sal NUMBER,
Insert into emp (FCST_DATE,LEVEL1,Sal) values ('01-MAR-11','175-12','1');
Insert into emp (FCST_DATE,LEVEL1,Sal) values ('01-JAN-11','319-10','100');
Insert into emp (FCST_DATE,LEVEL1,Sal) values ('01-AUG-11','175-1L','10');
select * from emp;
fcst_date Level1 Sal
01-JAN-11 319-10 100
01-AUG-11 175-1L 12
01-MAR-11 175-12 1
I want this table information in a file.
Can someone help!
PadmaHi Padu,
Use SQLPLUS commad SPOOL for exporting sql query result.
and see : Sqlplus – spool data to a flat file -
Export data from database table before database migration
Hello,
We are planning to migrate our SAP ERP 6 Ehp4/NW7.01 from Oracle 11.2 to IBM DB2 v. 9.7 database. During test migrations I have established that we spend a lot of time for one particular table (COEP). Because we donu2019t have possibility to archive this table before migration I have an idea to export data from previous years from this table to the file system (using an ABAP report), delete those data from table before migration and then after migration, import back to the database from the file system.
Does anybody have any concerns or suggestions about this idea?
Thank you for your answers
AndrejHello Andrej,
I strongly do not recommend to do so.
I am not sure whether technically this could work at all..
Even it if would work .. In order to really save time, the export and the import would have to be a dirty one (meaning the system is operational and in production). With this there is a high risk to produce inconsistencies on this table. And you most likely will receive no support if something unforeseen happens and you end with problems.
Also your approach (if it should work at all) , would have to be tested thoroughly by you , also protecting the table from any changes.
I do not believe that this can save any effort compared to implementing advanced migration techniques like table splitting.
On top, you would go high risk to end with an unsupported system, with not using official migration procedures
Hans-Juergen -
Can we export DATA from all tables in a schema?
Hi,
I have a question; Can we export all the DATA from all the tables present in the schema to any source (eigther CSV, TXT, DAt, etc..)?
Or
Can I have a PL/SQL procedure to display DATA from all Tables in a schema?
With Best Regards,
- NaveedHi,
This is pretty much what you need.
DECLARE
V_COUNT NUMBER;
v_sql varchar2(1000);
IN_OWNER_NAME VARCHAR2(100) := 'AP' ; -- SCHEMA NAME
TYPE T_COL_NAME is table of varchar2(1000) index by binary_integer;
v_col_tbl t_col_name;
BEGIN
FOR i in
(SELECT object_name
FROM dba_objects
WHERE owner = IN_OWNER_NAME
AND object_type ='TABLE'
and rownum < 2)
LOOP
v_sql := 'SELECT COUNT(*) FROM ' || i.object_name ;
EXECUTE IMMEDIATE v_sql INTO V_COUNT;
if v_count > 0 then
v_sql := 'SELECT * FROM ' || i.object_name ;
select column_name
bulk collect
into v_col_tbl
from DBA_TAB_COLUMNS
WHERE TABLE_NAME = I.OBJECT_NAME
AND OWNER = IN_OWNER_NAME;
-- start selecting the column and exporting using the column names selected.
end if;
if v_col_tbl.count > 0 then
for i in v_col_tbl.first .. v_col_tbl.last
loop
DBMS_OUTPUT.PUT_lINE(v_col_tbl(i));
end loop;
end if;
DBMS_OUTPUT.PUT_lINE( i.object_name || '-' || v_count);
END LOOP;
END;
- Ronel
Maybe you are looking for
-
Why can't i install ios 6.1.4 to my iphone 5? I hate ios 7!
So, the ios 7 is very nice and i like to see, but the 3g switcher is missing, so my baterry is die.... SO help me!!! I want to downgrade ios 6!!!!
-
Adobe Premiere does not appear as an available app in Adobe Application Manager. Why?
When I signed up for Creative Cloud there are a number of products that appear in the Apps portion of the Creative Cloud site, but when I try to download Premiere Pro it doesn't appear as one of the applications I have in the Adobe Application Manage
-
Been acting up what should i do
once i downloaded ios 6 for my ipod touch 4g the appd have been acting up what should i do
-
HANA views connection to Tibco Spotfire
Hello, I am working with Tibco Spotfire version 6.5. I can consume tables in HANA system but I am unable to consume the HANA views. Can I connect to HANA views from the tool? If so, how do I? Thanks in advance!
-
Blackberry Desktop Software a Problem
I am pissed off trying to install Blackberry desktop Software on My PC. The CD that comes along with the Handset is a **bleep**, it doesnt work and my PC gets hang when i use it, although i tried to download Desktop software from Internet but then so