Hex string upload as blob data to sql server

It need to open a file and read the content and upload to sql server(2005) as blob data.
But it seems give error as the attached screen.
So I tried to convert the file content string to hex string, but it take quite long time.
Is there any way to shorten the time or any other ways.
Any suggestion, thanks.
Attachments:
ss.png ‏73 KB

Try this.

Similar Messages

  • Upload csv file data to sql server tables

    Hi all,
    I want clients to upload csv file from their machines to the server.
    Then the program should read all the data from the csv file and do a bulk insert into the SQL Server tables.
    Please help me of how to go about doing this.
    Thanx in advance.....

    1) Use a multipart form with input type="file" to let the client choose a file.
    2) Get the binary stream and put it in a BufferedReader.
    3) Read each line and map it to a DTO and add each DTO to a list.
    4) Persist the list of DTO's.
    Helpful links:
    1) http://www.google.com/search?q=jsp+upload+file
    2) http://www.google.com/search?q=java+io+tutorial
    3) http://www.google.com/search?q=java+bufferedreader+readline
    4) http://www.google.com/search?q=jdbc+tutorial and http://www.google.com/search?q=sql+tutorial

  • Can't selectively delete image datatype BLOB data on SQL Server

    Hi all,
    I have a huge amount of BLOB data on an SQL Server 2008 DB (10.0.5500), in a table with an image datatype column. I need to selectively delete it from datafiles using a where filter on the table.
    I tried to use UPDATETEXT dbo.TBL_EMAILOUTBOUND_DSC.DESC_RAWDATA
    @ptrval 0 NULL; 
    loading the pointer with a previous filtered select, according
    documentation it should work, but it's not true. Do I make any mistake or forget something? If you need I can show the hole script.
    Thank you in advance
    Andrea
    Andrea

    Great to hear that it worked out!
    Below is detailed data of test. Thank you all.
    sp_spaceused
    name rows
    reserved data
    index_size unused
    TBL_EMAILOUTBOUND_RD_NEW 4768        --> 8156504 KB
    8156128 KB 24 KB
    352 KB
    update table_name set LOBcolumnName = null;
    name rows
    reserved data
    index_size unused
    TBL_EMAILOUTBOUND_RD_NEW 4768        --> 2456 KB
    2112 KB 24 KB
    320 KB
    ALTER INDEX ALL ON tbl REORGANIZE 
    name rows
    reserved data
    index_size unused
    TBL_EMAILOUTBOUND_RD_NEW 4768        --> 176 KB
    144 KB 24 KB
    8 KB
    Andrea

  • How to transfer BLOB type of data from SQL Server to Oracle

    Hi,
    Actually, I create a table with BLOB type data in SQL server. In fact, there is not exact BLOB type in SQL server, it will be separated to image and ntext types. But there is exact BLOB type in Oracle.
    I don't know how to transfer this "BLOB" type into Oracle with DTS or any other methods.
    Many Thanks for your any suggestions,
    Cathy

    JAVA_GREEN wrote:
    No i haven't mixed up.But the file from where i have to retrieve the data is in csv format.Even though i created another csv driver.and tried but i cud not find a solution to load/transfer a set of records from one file(in Excel/csv format) to another file(in mdb format).plz help me.Is there any other methods for this data transfer.A csv file is NOT an excel file.
    The fact that Excel can import a csv file doesn't make it an excel file.
    If you have a csv file then you must use a csv driver or just use other code (not jdbc) to access it. There is, normally, a ODBC (nothing to do with java) text driver that can do that.

  • Migrating a table with BLOB field from SQL-Server to Oracle.

    Hi All,
    I'm trying to create a Class to migrate data from SQL-Server to Oracle, this table has a BLOB field.
    The Code:
    package br.com.infox;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public class Migrador {
         public static void main(String[] args){
              try {
                   // Conex�o com o SQL Server
                   Class.forName("net.sourceforge.jtds.jdbc.Driver");
                   Connection conSQL = DriverManager.getConnection ("jdbc:jtds:sqlserver://10.10.2.9/protocolo","prot","suinf2002");
                   // Conex�o com o Oracle
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   Connection conORA = DriverManager.getConnection ("jdbc:oracle:thin:@10.10.2.2:1521:des","protocolo","protocolo");
                   Statement stSQL = conSQL.createStatement();
                   String querySQL = "SELECT * FROM DOC_INCORPORADO";
                   ResultSet rsSQL = stSQL.executeQuery(querySQL);
                   String queryORA = "INSERT INTO PROT_VITALICIAMENTO (NU_PROCESSO, ANO_PROCESSO, CD_USUARIO, DT_ENVIO," +
                             "DE_COMPLEMENTO, NM_ARQUIVO, ARQUIVO, NU_SEQ, CD_TIPO_ARQUIVO, MES, ANO) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
                   PreparedStatement psORA = conORA.prepareStatement(queryORA);
                   while (rsSQL.next()){
                        System.out.println("Linha: " + rsSQL.getRow());
                        psORA.setInt(1, rsSQL.getInt("nu_processo"));
                        psORA.setInt(2, rsSQL.getInt("ano_processo"));
                        psORA.setInt(3, rsSQL.getInt("cd_usuario"));
                        psORA.setDate(4, rsSQL.getDate("dt_incorporacao"));
                        psORA.setString(5, rsSQL.getString("complemento"));
                        psORA.setString(6, rsSQL.getString("nm_arquivo"));
                        psORA.setBinaryStream(7, rsSQL.getBinaryStream("arquivo"), (int)rsSQL.getBlob("arquivo").length());
                        psORA.setInt(8, rsSQL.getInt("num_seq"));
                        psORA.setInt(9, rsSQL.getInt("cd_tipo_arquivo"));
                        psORA.setInt(10, rsSQL.getInt("mes"));
                        psORA.setInt(11, rsSQL.getInt("ano"));
                        psORA.executeUpdate();
                   stSQL.close();
                   psORA.close();
                   conORA.close();
                   conSQL.close();
              } catch (Exception e){
                   e.printStackTrace();
    The ERROR:
    java.sql.SQLException: Exce��o de E/S: Connection reset
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
         at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:3668)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1119)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2191)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2064)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2989)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:658)
         at br.com.infox.Migrador.main(Migrador.java:41)
    What's the problem of these Class?
    Thank's.

    Depending on the version of the database you have, you could use transportable tablespaces.
    http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96524/c04space.htm#9370

  • Error while exporting data from sql server to excel

    Hi,
    I am trying to export data from sql server to excel.
    The query that I used is s follows
    INSERT INTO OPENROWSET( 'Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\Folder1\abc.xls','select * from [Sheet1$A1:IV65000]')
    select 
    column1,column2.... from Table1
    I get the following error message while doing so..
    String or binary data would be truncated.
    The statement has been terminated.
    One of the column's holds data more than 225 characters.
    What is the way to correct this, i want the whole data of the colum in the excel sheet.

    I haven't had great luck with the INSERT INTO OPENROWSET method.  Can you try one of the many samples from one of these 3 links?
    http://www.excel-sql-server.com/excel-sql-server-import-export-using-vba.htm#Excel%20Data%20Export%20to%20SQL%20Server%20Test%20Code 
    http://www.mssqltips.com/sqlservertip/1540/insert-update-or-delete-data-in-sql-server-from-excel/
    https://www.simple-talk.com/sql/database-administration/getting-data-between-excel-and-sql-server-using-odbc--/
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • How to compare 2 dates in SQL Server 2000 DB using Java?

    How do you compare 2 dates in SQL Server 2000 DB using Java?
    Let's say we have two fields: Date Reported and Target Finish Date.
    Date Reported is 09-10-2004 09:55:55: PM
    Target Finish Date is 09-12-2004 11:59:59: PM
    What i want to happen is i want to convert both dates to days and get the difference of the two.
    can SQL Server 2000 DB do this?

    it doesnt wrk.
    ok here's what i did:
    iv tested a simple code for this case.
    I created a table name tblDate which has 3 columns namely date_ID, date_From (datatype datetime), date_To (datatype datetime).
    I inserted 1 row: date_ID has the value 1, date_From has the value 10/22/2004, and date_To has the value 10/24/2004.
    i run the java code below:
    int days = 0;
              String query = "SELECT date_From, date_To cast(date_From-date_To AS int) AS Diff FROM tblZoo WHERE date_ID = '1'";
              try
                   DBConnect db = new DBConnect();
                   db.openCon();
                   ResultSet rs = db.execute(query);
                   while(rs.next())
                        days = rs.getInt("Diff");
                   db.closeCon();                         
              catch (Exception ex)
                   System.out.println("Error on Execution: " + ex);
              return days;___________
    an error occurred: Error on Execution: java.lang.nullpointerexception

  • Importing Data into Sql Server 2012 from Excel Data

    Hi,
    I got errors like this when i am doing import data into sql server from excel Data. Can you please help us?
    - Executing (Error)
    Messages
    Error 0xc020901c: Data Flow Task 1: There was an error with Source - demotable$.Outputs[Excel Source Output].Columns[Comment] on Source - demotable$.Outputs[Excel Source Output]. The column status returned was: "Text was truncated or one
    or more characters had no match in the target code page.".
     (SQL Server Import and Export Wizard)
    Error 0xc020902a: Data Flow Task 1: The "Source - demotable$.Outputs[Excel Source Output].Columns[Comment]" failed because truncation occurred, and the truncation row disposition on "Source - demotable$.Outputs[Excel Source Output].Columns[Comment]"
    specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
     (SQL Server Import and Export Wizard)
    Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on Source - demotable$ returned error code 0xC020902A.  The component returned a failure code when the pipeline engine called PrimeOutput().
    The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the failure.
     (SQL Server Import and Export Wizard)

    Are you attempting to import into a newly made table or into an existing table? It looks like it's trying to insert data where it cannot be inserted (invalid column or lack of data size in your column).
    Try the following:
    1). In your excel sheet, highlight the whole sheet and make sure the cells are in 'text' form and try re-importing
    2). save the document as ms dos TEXT and import as a text document.
    3). double check your columns are correct for the data, for example if you have a column that has a string of 100 characters and your column is 'NvarChar(90)' - that might cause the error? Or just correct data type in your column
    3). If that doesn't work and you're inserting into a new table, try importing it as string first and writing a query to insert columns that should be float/integer or whatever. You may want to convert float texts to a 'bigint' first rather than string
    > float as that can cause problems if I remember correctly.

  • Import data from SQL Server to Oracle

    I have created a dblink in oracle to access the SQL database. I am able to run queries through the dblink and it works fine. I have created a test table on Oracle Server to import the data. The field named "description" has CLOB data type. The corresponding datatype on SQL Server is varchar(7000).
    When I insert the data from SQL Server, it completes successfully without any error but it truncates the data on CLOB field.
    If I run the select query in SQLPlus I can see the entire description.
    Select "description" from sql_view@dblink;
    -- the above works fine.
    CREATE table test
    (description CLOB);
    INSERT INTO TEST
    Select "description" from sql_view@dblink;
    -- this works but it truncates the data after 256 characters
    My question is, how to get the data from SQL Server without truncating characters.
    Thanks in advance,
    Gopal

    I hear the same from other friend that sql server truncated the leading zeros from the id column.
    I really don't have a solution for this but you can try the work around. Export the data to flat file and upload in oracle using SQL loader, as this would be much faster and efficient.

  • Script to export data frmo SQL Server 2014 to xls file

    Hi All:
    I want to export data form a table in SQl Server 2014 to an xls file.
    Currently I have a working script for SQL Server 2005 in the below lines, but the same script doesnot work for SQL Server 2014.
    set @outFileName='D:\Folder1\File1.xls'
    SET @QueryString = 'INSERT INTO OPENROWSET( ''Microsoft.Jet.OLEDB.4.0'', ' + @outFileName +                             
     ',''select * ' + 'from [Sheet1$A1:IV65000]'') select * from Table1 ' --order by CreatedDate'                             
    EXEC ( @QueryString )                  .
    I have checked on the web but didnot get a good answer. Please share with me if any one has a working script for SQL Server 2014.
    Thanks... Happy Diwali.. :)

    Ok, I have downloaded the exe from the above link.
    As I have to install this on a production environment, I want to be sure of certain things ...
    Say I have installed the Provider, what would be the syntax for exporting the data from sql server 2014 to xls.
    It would certainly not be the same ... i feel.. please let me know.
    Thanks
    Yes
    provider connection string would be different
    like
    INSERT INTO OPENROWSET("Microsoft.ACE.OLEDB.12.0", "Excel 12.0;Database=<full file name>.xlsx;HDR=YES", "SELECT * FROM [SheetName$]")
    SELECT ..
    FROM table
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Faster way to migrate data from SQL Server to Oracle 10g

    We have to migrate data from SQL Server to Oracle 10 g.
    One particular table on SQL Server has records around 1.25 millions.
    We tried moving data using DTS package, but looks it will take hours with current speed of 300 records/minute.
    This table has TEXT column, which has XML strings stored. I am not sure, if this is the reason for slow migration.
    Would you please suggest better options to migrate it faster?
    Thanks in advance !!!

    Have you tried Migration work bench?

  • Exporting data from SQL Server database to Oracle database

    Hello All,
    We need to replicate a table's data of SQL Server database to Oracle database.
    Can this task be accomplished using Import/Export wizard or Linked servers?
    Can help me regarding which Oracle data access components should i download to do this?
    I am using SQL Server 2012.
    And i have Oracle 11g release 2 client installed in my system.
    Thanks in Advance.
    Thanks and Regards, Readers please vote for my posts if the questions i asked are helpful.

    Yes you can definitely transfer data from SQL server to Oracle Have a look at below links
    Export SQL server data to Oracle Using SSIS
    Use OLEDB data provider to transfer data from SQL server to Oracle
    Using Import Export Wizard
    Similar thread
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • Error while reversing data from SQL Server to ODI

    hi,
    I was reversing data from SQL Server Java 1.6_022 in ODI Java 1.5, I was getting error Version Mismatch and I updated ODI Java version to 1.6_022.
    And now, I am getting the below error while reversing the data from SQL Server database.
    0 : 08001 : java.sql.SQLException: No suitable driver
    Looking for the assistance on the same.
    Thanks,
    Abhay

    If everything is fine the reversing should be fine. I would say check again if the Technology of the Model and the also the dataserver is created under the right Technology in topology too.
    also if this doesn't help , Please tell us the steps you have carried so far . Also can you try selective reverse is it showing the tables.

  • How to retrieve Min(startDate) and Max(endDate) for different groups of data? (sql server 2000)

    My sample dataset (below) contains 3 groups -- 'a', 'b', 'c'.  I need to retrieve the Min(startDate) and Max(EndDate) for each group so that the output looks something like this (date format not an issue):
    fk   minStart       maxEnd
    a    1/13/1985    12/31/2003
    b    2/14/1986    12/31/2003
    c    4/26/1987    12/31/2002
    What is the Tsql to perform this type of operation?  Note:  the actual data resides in a sql server 2000 DB.  If the Tsql is different between version 2000 and the later versions -- I would be grateful for both versions of the Tsql
    --I noticed that multiple lines of Insert values doesn't work in Sql Server 2000 -- this sample is in Sql Server 2008
    create table #tmp2(rowID int Identity(1,1), fk varchar(1), startDate datetime, endDate datetime)
    insert into #tmp2
    values
    ('a', '1/13/1985', '12/31/1999'),
    ('a', '3/17/1992', '12/31/1997'),
    ('a', '4/21/1987', '12/31/2003'),
    ('b', '2/14/1986', '12/31/2003'),
    ('b', '5/30/1993', '12/31/2001'),
    ('b', '6/15/1994', '12/31/2003'),
    ('b', '7/7/2001', '12/31/2003'),
    ('c', '4/26/1987', '12/31/1991'),
    ('c', '8/14/1992', '12/31/1998'),
    ('c', '9/10/1995', '12/31/2002'),
    ('c', '10/9/1996', '12/31/2000')
    Thanks
    Rich P

    Rich
    It is unclear what you are trying to achieve, you said that it is SQL Server 2000 but provide a sample data with SQL Server 2008 syntax
    Is it possible to use UNION ALL for your queries to make its one 
    select * from
    select * from #tmp2 t1 where exists
    (select * from (select top 1 * from #tmp2 t2 where t2.fk = t1.fk order by t2.startdate) x where x.rowID = t1.rowID)
    UNION ALL
    select * from #tmp2 t1 where exists
    (select * from (select top 1 * from #tmp2 t2 where t2.fk = t1.fk order by t2.Enddate desc) x where x.rowID = t1.rowID)
     as  der order by fk
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Extract the data from SQL Server and Import into Oracle

    Hi,
    I would like to run a daily job that will export the table data from SQL server table (it will be only one or two table) and Import back into Oracle table (it might one or two table tables).
    Could you please guide me that how can i do this using either sql server or oracle?
    We have oracle 9.2 and sql server 2005.
    Normally i do from flat file which is generated by source destination nand i dump into oracle using sql*loader but this time I have to directly extract/export the data from MS Sql server and load into Oracle table, mostly it will reload so i might doing any massaging data during the load.
    If you show me the detail approach, it will be really appreciated.
    I have access to Sql server but i don't how to use sql server to do this or using oracle as a daily job even becuase have to schedule the job for this as it will be a daily job.
    Thanks,
    poratips

    Unless you can find an open source ODBC driver for SQL Server that runs on Solaris (and I wouldn't be overly hopeful there) Heterogeneous Services would require that you license something-- a third party ODBC driver, a new Oracle instance, or an Oracle Transparent Gateway.
    As I stated below, you could certainly use SQL Server's ETL tool, DTS. Oracle's ETL tools would require additional licensing since you're just on 9.2. You could also write a small application (Java or otherwise) that connected to both databases and transferred the data. If you're particularly enterprising, you could load the SQL Server Type 4 JDBC driver into Oracle's JVM and write a Java stored procedure that connected to the SQL Server database via JDBC, but that's a pretty convoluted approach.
    Justin

Maybe you are looking for