Dump table model to text file/

Hello,
How can i write my table model to a txt file, but i want to keep the table properties as: column width, height , etc.
Regards,
eyal

Hello,
How can i write my table model to a txt file, but i
want to keep the table properties as: column width,
height , etc.
Regards,
eyalHello esegev
You can save column width, height as properties in a file.
columnNames=new String[table.getColumnCount()];
for (int i=0;i<columnNames.length;i=i+1)
      columnNames[ i ]=table.getColumnModel().getColumn(i).getHeaderValue().toString();
data=new String[columnNames.length*table.getRowCount()];
j=0;
for (int i=0;i< table.getRowCount();i=i+1)
data[j]=table.getValueAt(i,0).toString();
data[j+1]=table.getValueAt(i,1).toString();
data[j+2]=table.getValueAt(i,2).toString();
j=j+3;//for 3 Cols
File file = new File("myTable.CSV");
String fileData;
if (file != null)
     try
          BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file,true));
          PrintWriter fileWriter = new PrintWriter(bufferedWriter);
          System.out.println("Column Headers ");
               for(int j=0; j <  table.getColumnCount(); ++j)
                                fileData=columnNames[ i ];
                    fileWriter.print(fileData+",");
        System.out.println("Done.... ");
          fileWriter.println("");
          System.out.println("Exporting Data ");
          for(int i=0; i<table.getRowCount(); ++i)
               for(int j=0; j < table.getColumnCount(); ++j)
                    fileData = table.getValueAt(i,j).toString();
                    fileWriter.print(fileData+",");
               fileWriter.println("");
          fileWriter.close();
        System.out.println("Done.... ");--
you can save JTable in CSV format.
while reading just use readLine and then use StringTokenizer
---

Similar Messages

  • How to dump table to the flat file, if the table has NVARCHAR data type fie

    I need to dump the table to the text file. The table has NVARCHAR data type field and simple select * from table_name does not work. What do I have to do? Do I need convert NVARCHAR to VARCHAR and if yes, then how?
    Thanks,
    Oleg

    I need to dump the table to the text file. The table has NVARCHAR data type field and simple select * from table_name does not work. What do I have to do? Do I need convert NVARCHAR to VARCHAR and if yes, then how?
    Thanks,
    Oleg

  • Hash Table copy to Text file : urgent

    HI
    I have a hash Table which cintaine id's and name pair Now i want to copy or dump this whole table into a Text file, But i do not know how to do this .
    This is very urgent for me.
    Please help me .
    Preeti

    HashTable is Serializable
    use ObjectOutputStream to write to the file and use ObjectInputStream to read from the file
    HashTable ht=new HashTable()
    ht.put("key1","value1");
    ht.put("key2","value2");
    FileOutputStream ostream = new FileOutputStream
    ("Hash.txt");
    ObjectOutputStream oos = new ObjectOutputStream(ostream);
    oos.writeObject(ht);
    oos.flush();
    oos.close();//dont forget thisuse ObjectInputStream To read HashTable from file
    use readObject() method

  • Download Internal Table into a Text File in BSP?

    I have an internal table which i need to download into my local pc. I know i can not use FM gui_download. Could some one please post code on how to download the internal table into a text file in BSP. Also i am not sure if i can use save dialog FM. Also need suggestion on which FM to use for save dialog which tells where to save the file.
    Any help will be appreciated.
    Thanks
    Nahman

    This might be a good starting point.
    <a href="/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table">/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table</a>

  • HOW CAN I SEND A TABLE TO A TEXT FILE

    Hi,
          I have a table with a lot of values , and i need to transfer this table to a text file (.txt) , without lose the position
    of this values in that table .Someone can help me with this? 
    Thx  
    Solved!
    Go to Solution.

    There is some conflicting and incorrect information here. First, to get the column headers of a table, you use a property node and the property 'Column Header Strings[]'. This is a string array and you can append it to the 2D string array that is the table contents.
    In 6.0, the Write to Spreadsheet File was not able to write a string array. However, there are instructions on the block diagram that describe what needs to be modified. After making the modifications, save the VI with a new name and in a new location.  I know for a fact that the modified VI has been posted to the forum. You can do a search but the actual modifications should take less time.

  • Downloading two internal tables in same text file

    I have one internal table as like below.
    Data:begin of itab1 occurs 0,
         rec(5),
         end of itab1.
    Itab1 is getting updated from input text file(Continuous text).
    Here Itab1 contains one record with Indicator '01 and n number of records with indicator '02'.
    This needs to be seperated in to two internal tables.
    data:Begin of Itab_Head occurs 0,
         Rec_ind(2) type C,
         Name(3) type C,
         end of itab_Head.
    data:Begin of Itab_Item occurs 0,
         Rec_ind(2) type C,
         Id(3) type C,
         Status(10,
         end of itab_Item.
    loop at itab1.
    If itab1-Rec+0(2) = '01'.
       Itab_Head-Rec_Ind = itab1-rec+0(2).
       Itab_Head-Name = itab1-rec+2(3).
       Append Itab_Head.
    elseif itab1-rec+0(2) = '02'.
       Itab_Item-Rec_Ind = itab1-rec+0(2).
       Itab_Item-Id = itab1-rec+2(3).
       Append Itab_Item.
    endif.
    endloop.
    After moving to the internal tables I am doing some processing and updating the status of Itab_item.
    After all these again I have to download the internal table as a text file.Now my question is.
    I have values in 2 diff internal tables.How to download the two in same file.

    See this sample code.
    data: itab1 type string occurs 0 with header line,
          itab2 type string occurs 0 with header line.
    itab1 = 'itab1_text'.
    append itab1.
    itab2 = 'itab2_text'.
    append itab2.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        exporting
          FILENAME = 'C:\ftext.txt'
        APPEND = 'X'
        changing
         DATA_TAB = itab1[].
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        exporting
          FILENAME = 'C:\ftext.txt'
          APPEND = 'X'
        changing
         DATA_TAB = itab2[].
    Svetlin

  • Internal table to a text file in Unix

    Hi ,
    I was trying to download data from Internal table to a text file in Unix.
    How do I do this?
    One more thing is the fields on each record of the file should be delimited by the”!” (pipe) character.
    Any one please me with the code.
    Thanks

    check these links...
    ASCII value
    ASCII value
    Creating a Unix File
    or do you mean application server?
    then use open dataset. transfer and close dataset.
    example:
    DATA: e_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.     
      open dataset e_file for output in text mode.
      lOOP AT it_datatab......
        transfer it_datatab to e_file.
      ENDLOOP.
      close dataset e_file.
    regds,
    kiran

  • Sql/Plsql code to store data into a temporary table from a text file

    Dear all,
    I need to create a temporary table getting data from a text file. I am very new to data loading could you please help me how to read the text file in to a temporary table.
    i have text file like as below:
    order* items : books Purchasing
    start date:
    8-11-09
    Notes: Books are selling from aug10 to aug 25
    Action performed*
    Time*
    Verified By*
    sold* out from shop, sold out date:_________
    +1.+
    physics _______ book sold to ravi
    +2.+
    social _______ book this is a good book
    sold to kiran
    aug10th
    ronald
    +3.+
    maths book to sal
    +4.+
    english book__________ this was a newbook
    to raj
    jak
    return* to shop, return date:____________
    +1.+
    maths book return by:_____________ Verify book
    aug11th
    john
    +2.+
    story book by:_________ checked
    aug14th
    Now i need to create a temporary table with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
    Now i need to create a temporary table named as books_order with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
    Order               status     Action_Performed                         Time               Verified_By
    books Purchasing     sold          physics _______ book sold to ravi               _______          _________
    books Purchasing     sold          social _______ book this is a good book sold to kiran aug10th               ronald
    books Purchasing sold          maths book to sal                         _____               __________
    books Purchasing     sold          english book__________ this was a newbook to raj __________          jak
    books Purchasing return     maths book return by:_____________ Verify book      aug11th               john
    books Purchasing     return     story book by:_________ checked                aug14th               _________
    Thanks in advance.

    Hi,
    Thanks for your suggestions. I Was able to get the data using utl_file.get_line. But i was not able to the data if it is in the below format:
    I was able to read the data and storing if it is in the same line.But i dont know how to read below data
    Book. Type Name Location Ownership Code
    Story SL hyd SS-HYD
    In this data i have to search for 'Book. type' and then i need to save the word 'Story' to the column 'Book_type'
    Then i need to search for 'Name' and i need to save 'SL' into the column into 'Name'
    Then i need to search for 'Location' and i need to save 'hyd' into the column into 'Location'
    I was able to extract the data if it is in below format using utl_file.get_line
    Known Author: Unknown
    Less Selling Factors: Thunderstorms
    Reason: Unknown
    Any one can explain me how to solve the above criteria.
    Below i am explaining the same problem in detail.
    I have a text file as below and i have a table having 12 columns. Now i need to insert this text file into the table story_books.
    CREATE TABLE story_books
    book_id NUMBER,
    Category VARCHAR2(100 BYTE),
    Book_type VARCHAR2(100 BYTE),
    Name VARCHAR2(700 BYTE),
    Location VARCHAR2(700 BYTE),
    Ownership_code VARCHAR2(700 BYTE),
    Author VARCHAR2(700 BYTE),
    Less_Sel_fact VARCHAR2(700 BYTE),
    Reason VARCHAR2(700 BYTE),
    Buying VARCHAR2(700 BYTE),
    Suspected Book VARCHAR2(700 BYTE),
    Conditions VARCHAR2(700 BYTE)
    -------------------------text file---------------
    Books Out Table: Books
    Book. Type Name Location Ownership Code
    Story SL hyd SS-HYD
    Known Author: Unknown
    Less Selling Factors: Thunderstorms
    Reason: Unknown
    Buying (if applicable):
    Not Applicable
    Suspected Book:
    Unknown
    Conditions to increace sales:
    Advertisement in all areas
    i was able to read the data and storing if it is in the same line.But i dont know how to read below data
    Book. Type Name Location Ownership Code
    Story SL hyd SS-HYD
    In this data i have to search for 'Book. type' and then i need to save the word 'Story' to the column 'Book_type'
    Then i need to search for 'Name' and i need to save 'SL' into the column into 'Name'
    Then i need to search for 'Location' and i need to save 'hyd' into the column into 'Location'
    I was able to extract the data if it is in below format using utl_file.get_line
    Known Author: Unknown
    Less Selling Factors: Thunderstorms
    Reason: Unknown
    Any one can explain me how to solve the above criteria.
    Thanks in advance.

  • Sql/Plsql code to export data into a temporary table from a text file

    Dear all,
    I need to create a temporary table getting data from a text file. I am very new to data loading could you please help me how to read the text file in to a temporary table.
    i have text file like as below:
    order items : books Purchasing
    start date:
    8-11-09
    Notes: Books are selling from aug10 to aug 25
    Action performed
    Time
    Verified By
    sold out from shop, sold out date:_________
    1.
    physics _______ book sold to ravi
    2.
    social _______ book this is a good book
    sold to kiran
    aug10th
    ronald
    3.
    maths book to sal
    4.
    english book__________ this was a newbook
    to raj
    jak
    return to shop, return date:____________
    1.
    maths book return by:_____________ Verify book
    aug11th
    john
    2.
    story book by:_________ checked
    aug14th
    Now i need to create a temporary table and insert the data into the table from this text file.
    Now i need to create a temporary table named as books_order with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
    Order     status     Action_Performed     Time     Verified_By
    books Purchasing     sold     physics _______ book sold to ravi     _______     _________
    books Purchasing     sold     social _______ book this is a good book sold to kiran aug10th     ronald
    books Purchasing sold     maths book to sal     _____     __________
    books Purchasing     sold     english book__________ this was a newbook to raj __________     jak
    books Purchasing return     maths book return by:_____________ Verify book aug11th     john
    books Purchasing     return     story book by:_________ checked aug14th     _________
    Thanks in advance.

    Isn't school work marvelous?
    Create an external table.
    http://www.morganslibrary.org/reference/externaltab.html
    Getting the data into a temporary table may make sense in SQL Server ... but not in Oracle.

  • Wirte the content of an internal table into a text file

    Hello Experts,
    how can I wirte the content of an internal table into a text file and putit on my local
    desktop ?
    Regards
    ertas

    Hi,
      You can use the FM GUI_DOWNLOAD for this purpose.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                    =
        FILENAME                        = 'c:\testmmv.txt'
      FILETYPE                        = 'ASC'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = ' '
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
      WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
      SHOW_TRANSFER_STATUS            = ABAP_TRUE
    IMPORTING
      FILELENGTH                      =
      TABLES
        DATA_TAB                        = LT_STR
      FIELDNAMES                      = 
    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
       OTHERS                          = 22
    IF SY-SUBRC <> 0.
    Implement suitable error handling here
    ENDIF.
    With regards,
    Vamsi

  • Exporting table data into text files

    I got a request to export the data from about 85 tables into 85 text files. I assume that they will want a header row and some delimiter character. This is a process that must run every night by a sql job.
    Obviously I want it to be flexible. Tables could be addede and removed and columns could be added and removed. There will probably be a control table that has the list of tables to export.
    Looked at bcp - but seems that it is command line only?
    SSIS package?
    What other options are there?

    Wanted to post my solution. Ended up using bcp in a PowerShell Script. I was unable to use bcp in SQL because it requires xp_cmdshell and that is not allowed at many of our client sites. So wrote a Powershell script that executes bcp. The ps script
    loops through a table that contains a row for each table/view to export along with many values and switches for the table/view export: export path, include column headers, enclose each field in double quotes, double up embedded double quotes, how to format
    dates, what to return for NULL integers - basically the stuff that is not flexible in bcp. To get this flexibility I created a SQL proc that takes these values as input and creates a view. Then the PS bcp does a SELECT on the view. Many of my tables are
    very wide and bcp has a limit of 4000/8000. Some of my SELECT statements ended up being GT 35k in length. So using a view got around this size limitation.
    Anyway, the view creation and bcp download is really fast. It can download about 4 gb of data in 20 minutes. It can download it faster the 7z can zip it.
    Below is the SQL proc to format the SELECT statement to create the view for bcp (or some other utility like SQLCMD, Invoke-SQLCMD) or SQL query by "SELECT * from v_ExportData". the proc can be used from SQL or PS, or anything that can call a SQL
    Proc and then read a SQL view.
    IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExportTablesCreateView]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[ExportTablesCreateView]
    GO
    CREATE PROCEDURE [dbo].[ExportTablesCreateView]
    ExportTablesCreateView
    Description:
    Read in a tablename or viewname with parameters and create a view v_ExportTable of the
    data. The view will typically be read by bcp to download SQL table data to flat files.
    bcp does not have the options to include column headers, include fields in double quotes,
    format dates or use '0' for integer NULLS. Also, bcp has a limit of varhar 4000 and
    wider tables could not be directly called by bcp. So create the v_ExportTable and have
    bcp SELECT v_ExportTable instead of the original table or view.
    Parameters:
    @pTableName VARCHAR(128) - table or view to create v_ExportTable from
    @pColumnHeader INT =1 - include column headers in the first row
    @pDoubleQuoteFields INT = 1 - put double quotes " around all column values including column headers
    @pDouble_EmbeddedDoubleQuotes INT = 1 - This is usually used with @pDoubleQuoteFields INT = 1. 'ab"c"d would be 'ab""c""d.
    @pNumNULLValue VARCHAR(1) = '0' - NULL number data types will export this value instead of bcp default of ''
    @pDateTimeFormat INT = 121 - DateTime data types will use this format value
    Example:
    EXEC ExportTablesCreateView 'custname', 1, 1, 1, '0', 121
    @pTableName VARCHAR(128),
    @pColumnHeader INT = 1,
    @pDoubleQuoteFields INT = 1,
    @pDouble_EmbeddedDoubleQuotes INT = 1,
    @pNumNULLValue VARCHAR(1) = '0',
    @pDateTimeFormat INT = 121
    AS
    BEGIN
    DECLARE @columnname varchar(128)
    DECLARE @columnsize int
    DECLARE @data_type varchar(128)
    DECLARE @HeaderRow nvarchar(max)
    DECLARE @ColumnSelect nvarchar(max)
    DECLARE @SQLSelect nvarchar(max)
    DECLARE @SQLCommand nvarchar(max)
    DECLARE @ReturnCode INT
    DECLARE @Note VARCHAR(500)
    DECLARE db_cursor CURSOR FOR
    SELECT COLUMN_NAME, ISNULL(Character_maximum_length,0), Data_type
    FROM [INFORMATION_SCHEMA].[COLUMNS]
    WHERE TABLE_NAME = @pTableName AND TABLE_SCHEMA='dbo'
    OPEN db_cursor
    FETCH NEXT FROM db_cursor INTO @ColumnName, @ColumnSize, @Data_type
    SET @HeaderRow = ''
    SET @ColumnSelect = ''
    -- Loop through each of the @pTableColumns to build the SELECT Statement
    WHILE @@FETCH_STATUS = 0
    BEGIN
    BEGIN TRY
    -- Put double quotes around each field - example "MARIA","SHARAPOVA"
    IF @pDoubleQuoteFields = 1
    BEGIN
    -- Include column headers in the first row - example "FirstName","LastName"
    IF @pColumnHeader = 1
    SET @HeaderRow = @HeaderRow + '''"' + @ColumnName + '"'' as ''' + @columnname + ''','
    -- Unsupported Export data type returns "" - example "",
    IF @Data_Type in ('image', 'varbinary', 'binary', 'timestamp', 'cursor', 'hierarchyid', 'sql_variant', 'xml', 'table', 'spatial Types')
    SET @ColumnSelect = @ColumnSelect + '''""'' as [' + @ColumnName + '],'
    -- Format DateTime data types according to input parameter
    ELSE IF @Data_Type in ('datetime', 'smalldatetime', 'datetime2', 'date', 'datetimeoffset')
    -- example - CASE when [aaa] IS NULL THEN '""' ELSE QUOTENAME(CONVERT(VARCHAR,[aaa], 121), CHAR(34)) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN ''""'' ELSE QUOTENAME(CONVERT(VARCHAR,[' + @columnname + '],' + CONVERT(VARCHAR,@pDateTimeFormat) + '), CHAR(34)) END AS [' + @ColumnName + '],'
    -- SET Numeric data types with NULL value according to input parameter
    ELSE IF @Data_Type in ('bigint', 'numeric', 'bit', 'smallint', 'decimal', 'smallmoney', 'int', 'tinyint', 'money', 'float', 'real')
    -- example - CASE when [aaa] IS NULL THEN '"0"' ELSE QUOTENAME([aaa], CHAR(34)) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN ''"' + @pNumNULLValue + '"'' ELSE QUOTENAME([' + @columnname + '], CHAR(34)) END AS [' + @ColumnName + '],'
    ELSE
    -- Double embedded double quotes - example "abc"d"ed" to "abc""d""ed". Only applicible for character data types.
    IF @pDouble_EmbeddedDoubleQuotes = 1
    BEGIN
    -- example - CASE when [aaa] IS NULL THEN '""' ELSE '"' + REPLACE([aaa],'"','""') + '"' END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @ColumnName + '] IS NULL THEN ''""'' ELSE ''"'' + REPLACE([' + @ColumnName + '],''"'',''""'') + ''"'' END AS [' + @ColumnName + '],'
    END
    -- DO NOT PUT Double embedded double quotes - example "abc"d"ed" unchanged to "abc"d"ed"
    ELSE
    BEGIN
    -- example - CASE when [aaa] IS NULL THEN '""' ELSE '"' + [aaa] + '"' END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @ColumnName + '] IS NULL THEN ''""'' ELSE ''"'' + [' + @ColumnName + '] + ''"'' END AS [' + @ColumnName + '],'
    END
    END
    -- DO NOT PUT double quotes around each field - example MARIA,SHARAPOVA
    ELSE
    BEGIN
    -- Include column headers in the first row - example "FirstName","LastName"
    IF @pColumnHeader = 1
    SET @HeaderRow = @HeaderRow + '''' + @ColumnName + ''' as ''' + @columnname + ''','
    -- Unsupported Export data type returns '' - example '',
    IF @Data_Type in ('image', 'varbinary', 'binary', 'timestamp', 'cursor', 'hierarchyid', 'sql_variant', 'xml', 'table', 'spatial Types')
    SET @ColumnSelect = @ColumnSelect + ''''' as [' + @ColumnName + '],'
    -- Format DateTime data types according to input parameter
    ELSE IF @Data_Type in ('datetime', 'smalldatetime', 'datetime2','date', 'datetimeoffset')
    -- example - CASE when [aaa] IS NULL THEN '''' ELSE CONVERT(VARCHAR,[aaa], 121) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN '''' ELSE CONVERT(VARCHAR,[' + @columnname + '],' + CONVERT(VARCHAR,@pDateTimeFormat) + ') END AS [' + @ColumnName + '],'
    -- SET Numeric data types with NULL value according to input parameter
    ELSE IF @Data_Type in ('bigint', 'numeric', 'bit', 'smallint', 'decimal', 'smallmoney', 'int', 'tinyint', 'money', 'float', 'real')
    -- example - CASE when [aaa] IS NULL THEN '"0"' ELSE CONVERT(VARCHAR, [aaa]) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN ''' + @pNumNULLValue + ''' ELSE CONVERT(VARCHAR,[' + @columnname + ']) END AS [' + @ColumnName + '],'
    ELSE
    BEGIN
    -- Double embedded double quotes - example "abc"d"ed" to "abc""d""ed". Only applicible for character data types.
    IF @pDouble_EmbeddedDoubleQuotes = 1
    -- example - CASE when [aaa] IS NULL THEN '' ELSE CONVERT(VARCHAR,REPLACE([aaa],'"','""')) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN '''' ELSE CONVERT(VARCHAR,REPLACE([' + @columnname + '],''"'',''""'')) END AS [' + @ColumnName + '],'
    ELSE
    -- example - CASE when [aaa] IS NULL THEN '' ELSE CONVERT(VARCHAR,[aaa]) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN '''' ELSE CONVERT(VARCHAR,[' + @columnname + ']) END AS [' + @ColumnName + '],'
    END
    END
    FETCH NEXT FROM db_cursor INTO @ColumnName, @ColumnSize, @Data_Type
    END TRY
    BEGIN CATCH
    RETURN (1)
    END CATCH
    END
    CLOSE db_cursor
    DEALLOCATE db_cursor
    BEGIN TRY
    -- remove last comma
    IF @pColumnHeader = 1
    SET @HeaderRow = SUBSTRING(@HeaderRow , 1, LEN(@HeaderRow ) - 1)
    SET @ColumnSelect = SUBSTRING(@ColumnSelect, 1, LEN(@ColumnSelect) - 1)
    -- Put on the finishing touches on the SELECT
    IF @pColumnHeader = 1
    SET @SQLSelect = 'SELECT ' + @HeaderRow + ' UNION ALL ' +
    'SELECT ' + @ColumnSelect + ' FROM [' + @pTableName + ']'
    ELSE
    SET @SQLSelect = 'SELECT ' + @ColumnSelect + ' FROM [' + @pTableName + ']'
    ---- diagnostics
    ---- PRINT truncates at 4k or 8k, not sure, my tables have many colummns
    --PRINT @SQLSelect
    --DECLARE @END varchar(max) = RIGHT(@SQLSelect, 3000)
    --PRINT @end
    --EXECUTE sp_executesql @SQLSelect
    -- drop view if exists -- using view because some tables are very wide. one of my tables had a 33k select statement
    SET @SQLCommand = '
    IF EXISTS (SELECT * FROM SYS.views WHERE name = ''v_ExportTable'')
    BEGIN
    DROP VIEW v_ExportTable
    END'
    EXECUTE @ReturnCode = sp_executesql @SQLCommand
    IF @returncode = 1
    BEGIN
    RETURN (1)
    END
    -- create the view
    SET @SQLCommand = '
    CREATE VIEW v_ExportTable AS ' + @SQLSelect
    -- diagnostics
    --print @sqlcommand
    EXECUTE @ReturnCode = sp_executesql @SQLCommand
    IF @returncode = 1
    BEGIN
    RETURN (1)
    END
    END TRY
    BEGIN CATCH
    RETURN (1)
    END CATCH
    RETURN (0)
    END -- CREATE PROCEDURE [dbo].[ExportTablesCreateView]
    GO

  • Dynamic table linking to text file

    Access 2013.accdb
    A large quantity of text files will be arriving to the user.  They will all have the same fixed width format, but their file names will vary, and their stored location.
    The data needs to be appended into Table1
    I am thinking this approach: Link to a model text file Model.txt, and as part of that normal table linking I can set up the fixed width definitions for the fields.  I have already done this ok. So I have this linked table 'Model1' in the navigation
    pane
    When a new text file comes the user will archive it in a folder:  New1.txt
    I can then get the path as a string: "C:blah blah \New1.txt" lets call this NewString
    So what I am thinking is in order to Append in the new data; to first dynamically change the link table path to Model1 into the NewString and refresh the connect.
    The AppendQuery is looking for Model1 so that table name must not change, and the fixed widths that were part of the Model1 initial linking must not change.
    Does this sound viable - and what is the code for Model1 table relinking?  Table Def connect properties is not something I've delved into and much of the research I've found is seriously old mdb vintage
    I do not think the import spec feature of 2013 allows a dynamic change in file location / name - though if I am wrong on this point please let me know.  And I think in terms of a TransferText import I would lose the fixed widths definition and
    it would come in only as a single field file.  So these are the reasons I am thinking of manipulating the table path connection.
    Definitely would welcome advice on this one.  TIA

    getting a path to a file is pretty straight forward code out there for Windows Explorer file selection:
    'file select
    Dim strFile As String
          With Application.FileDialog(1)
               If .Show Then
                   strFile = .SelectedItems(1)
               Else
                   MsgBox "No file selected", vbInformation
                   Exit Sub
               End If
           End With
    'end file select
    so strFile would be what I termed NewString in my original post;  I have found code to change links to Access tables and even excel files - but haven't found what works to a text file....the code that I've experimented with does not like the .connect
    refresh......

  • Export table data in text file

    hi,
    i am using oracle 8.0.7 , i want to export a table data in to text file, thanks in advance
    Noman ul haq

    2 options:
    1) Spool the query results into a file using SQL*PLUS
    2) If you can use the Oracle Server, look at the UTL_FILE package. This writes files, but ONLY to the Oracle server. It will NOT write out to your client machine. Your DBA will need to add an entry to allow for the UTL_FILE package to write out to the directory you choose.
    Hope that helps - the documentation should have detailed usage of UTL_FILE package. Or search on this site b/c this is a common question - see it at least 3 times a week.

  • Table update from text file on server

    How do I get a table in dreamweaver to update from a text
    file thats on the server it will be posted on? Do I need to use
    some sort of weird coldfusion or asp.net, or can i do it in basic
    html. It would be sweet to make happen for my portfolio news
    section ... thanks!

    Hello,
    What you need is to know the structure (fields) of your internal table LS_BKPF at runtime.
    The standard SAP class CL_ABAP_TYPEDESCR contains Methods to describe not only repository structures but also variables used in your ABAP program.
    DESCRIBE_BY_DATA : Description of data object type
    DESCRIBE_BY_NAME : Description of object type using relative/absolute names
    DESCRIBE_BY_OBJECT_REF : Description of object type using reference
    DESCRIBE_BY_DATA_REF : Description of data object type using reference
    Example on how to do this can be found here :
    [http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3414700)ID1687263150DB21033411053326729243End?blog=/pub/wlg/2071|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3414700)ID1687263150DB21033411053326729243End?blog=/pub/wlg/2071]
    After you have retrieved the fieldnames of your internal table at runtime you can add them in the first line of your dataset.
    Success.
    Wim

  • Dump SCOM Alerts to Text File

    Hi Guys, 
    Is there a way to dump scom alerts to a text file? 
    For example, I have created a monitor to detect a particular eventid. I want to dump this information (date/time, hostname, event description etc.) to a text file instead of the usual email or sms alert. 

    For Export SCOM Alerts to txt files, you can refer below links
    https://marckean.wordpress.com/2012/10/17/export-scom-2010-alerts-to-txtcsv-file-using-powershell/
    http://scug.be/dieter/2011/05/11/scom-dump-alerts-to-text-file-and-mail/
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer"Mai Ali | My blog:
    Technical | Twitter:
    Mai Ali

Maybe you are looking for

  • Maintain tolerance limits for tolerance key PE (CoCode S001)

    Dear all im getting error when i creating PO Maintain tolerance limits for tolerance key PE (CoCode S001) Please help me Regards venu gopal

  • WAAS WAE Alarm 'mstore_key_retrieval'

    Hello, I am supporting an environment that has 30+ remote WAEs deployed with a CM at the HQ. All remote WAE's Versions = Cisco Wide Area Application Services (universal-k9) Software Release 4.2.3b (build b4 Oct  4 2010) HQ's CM version = Cisco Wide A

  • How do now open two copies of same page

    As a business short cut I cut and paste from one copy of a web page to another copy. Your new feature disallows two copies of same page. Is there a way to force two copies?

  • Is the US iPhone 4 factory unlock?

    Hello friends, I live in Indonesia and I have a friend who stays in US and he will be going to Indonesia soon. I want him to buy me an iPhone 4 from the US but I was afraid that the US iPhone 4 is not factory unlock and it can't be used out of the US

  • Use of RMBWV3** report

    for clearing the lbwq queue we need to run the rmbwv3** report again and agian or it will done automatically, how deltas are coming into rsa7 is they are coming from the lbwq regards rubane