Sql server bulk insert blob filename parameter

My problem SQL script:
declare @filepath varchar(100)
set @filepath = 'E:\foto\1.jpg'
INSERT INTO [dbo].[MsQuestions] ([TestCategoryID], [LevelID], [TestTypeID], [QuestionText], [QuestionImg])
select  1 , 1, 8, 'data gambar',BulkColumn FROM OPENROWSET(BULK   @filepath , SINGLE_BLOB)
thanks.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%
string sConn = @"server=.; database=OnlineTesting; Integrated Security=True";
SqlConnection objConn = new SqlConnection(sConn);
objConn.Open();
string sTSQL = "exec sp_filenamea";
SqlCommand objCmd = new SqlCommand(sTSQL, objConn);
objCmd.CommandType = CommandType.Text;
SqlDataReader dr = objCmd.ExecuteReader();
dr.Read();
Response.BinaryWrite((byte[])dr["QuestionImg"]);
objConn.Close();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Exec SP</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

Perhaps this 
http://dimantdatabasesolutions.blogspot.co.il/2009/05/how-to-uploadmodify-more-than-one-blob.html
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

Similar Messages

  • SQL SERVER BULK FETCH AND INSERT/UPDATE?

    Hi All,
           I am currently working with C and SQL Server 2012. My requirement is to Bulk fetch the records and Insert/Update the same in the other table with some  business logic?
           How do i do this?
           Thanks in Advance.
    Regards
    Yogesh.B

    > is there a possibility that I can do a bulk fetch and place it in an array, even inside a stored procedure ?
    You can use Temporary tables or Table variables and have them indexes as well
    >After I have processed my records, tell me a way that I will NOT go, RECORD by RECORD basis, even inside a stored procedure ?
    As i said earlier, you can perform UPDATE these temporary tables or table variables and finally INSERT/ UPDATE your base table
    >Arrays are used just to minimize the traffic between the server and the program area. They are used for efficient processing.
    In your case you will first have to populate the array (Using some of your queries from the server) which means you will first load the arrary, do some updates, and then send them back to server therefore
    network engagement
    So I just gave you some thoughts I feel could be useful for your implementation, like we say, there are many ways so pick the one that works good for you in the long run with good scalability
    Good Luck! Please Mark This As Answer if it solved your issue. Please Vote This As Helpful if it helps to solve your issue

  • Sql Server bulk update

    Hi
    I have a datatable (in .net Application) which has a huge data.
    I need to update/insert the data in to  the Sql server database table.
     (Upadte if the data exist in the table and insert if the data does not exist in the table).
    just I wanted to know Is there any option for bulk insert or update rather than checking each row in (using cursor - SP) the table and inserting/updating..
    Samproo

    Hi Samproo, You will never use a cursor to check the existence of a record to whether update it or insert it. It will cost a lot to you when huge data stars flowing in.
    Just use the Exists statement as below.
    IF EXISTS(SELECT 1 FROM Table_Name WHERE condition = Value)
    BEGIN
    ......UPDATE DATA Statemet.....
    END
    ELSE
    BEGIN
    .......INSERT DATA Statement.......
    END
    And Yes, you can use this inside any stored procedure the same way it is.
    or if you doing matches between two tables then you can use MERGE as well...
    Please mark as answer, if this has helped you solve the issue.
    Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

  • SQL Server 2014 Express extract file parameter?

    I am working to bundle SQL Server 2014 Express with an application.  I am using the following command line to install via an InstallShield prerequisite:  /qs /INSTANCENAME=MYINSTANCE /ACTION="Install" /FEATURES=SQLEngine,Conn,SSMS
    /SECURITYMODE=SQL /SAPWD="Password" /TCPENABLED=1 /SQLSVCACCOUNT="NT AUTHORITY\SYSTEM" /IACCEPTSQLSERVERLICENSETERMS
    The installer I am using is SQLEXPRWT_x86_ENU.exe.
    When the installer starts up their is a dialog named:  Choose Directory for Extract Files.  In earlier versions of SQL Server Express this dialog did not require the user to press Ok to continue.  Since it takes several minutes to install
    SQL Server Express I prefer to show the installation to the user, so they can see that something is taking place.  The /q (Quiet) parameter will suppress this dialog, but nothing is seen for several minutes.  Note:  the Installer documentation
    does state that:  The /QS switch only shows progress, does not accept any input, and displays no error messages if encountered. The /QS parameter is only supported when /Action=install is specified.  Consequently, I believe the /QS parameter
    should not be requiring input.
    All that for these questions:
    1) Is there away to suppress this dialog while still using the /qs (Quiet Simple) parameter.
    2) Is there a parameter to tell the installer to extract the files to a specified location?
    Thanks,
    Les

    Hi,
    After you download the installation package of SQL Server Express 2014, and extracts it to the specified location, the dialog of “Choose Directory for Extract Files” will appear when you install the SQL Server Express. Usually, we need to use the following
    steps to extract the setup files to a temporary location.
    1.In the Command Prompt window type %USERPROFILE%\Downloads\ SQLEXPRWT_x86_ENU.exe /x
    2.When prompted to Choose Directory For Extracted Files type C:\SQLEXPR and click OK to extract the files.
    Or suppress the dialog to extract the right location in SQL Server Express 2008 or other lower version. Such as
    c:\temp>SQLEXPRWT_x64_ENU.exe /extract: "c:\temp".
    However, in SQL Server Express 2014, I do a test, we could not suppress the dialog or use the parameters directly to extract in command line. For more information about
    installing SQL Server 2014 from the Command Prompt, you can review the following article.
    http://msdn.microsoft.com/en-us/library/ms144259.aspx
    If necessary, personally, I recommend you can provide Microsoft a feature request at
    https://connect.microsoft.com/SQLServer so that we can try to modify and expand the product features based on your needs.
    Thanks,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Sending image from MS SQL SERVER to Oracle BLOB

    Hey all, we're trying update Oracle via a SQL Server linked server and we're having an issue with a blob column. The update from SQL is:
    UPDATE Banner..GENERAL.PS_EBI_IF_TBL
    set photo = a.blob_file, photo_change_date=a.blob_date
    from PWNT.dbo.BLOBS a, PWNT.dbo.BADGE_V b
    where a.ID = b.ID
    and base_name = b.BADGE_BASE_NAME
    and b.BADGE_blob_date > getdate()-.021
    GO
    The error we get is:
    OLE DB provider "OraOLEDB.Oracle" for linked server "Banner" returned message "ORA-01747: invalid user.table.column, table.column, or column specification".
    The syntax is correct, we can run it if the column being updated (photo) is not a blob, so we believe there is something else we have to do because of the blob. Has anybody done anything like this and know how it works? Thanks!
    Tom

    Given that there are no version numbers is your post I can imagine many possibilities for misconfiguration. Especially as an Oracle BLOB bears no direct size relationship to anything MS SQL could possibly support.

  • SQL Server Bulk Copy

    The performance optimization guide shows you how to switch between the SQL Server ODBC bulk copy API and SQLBulkOperations API but does not recomend which one works better. Since the default is SQL Server ODBC bulk copy API I assume that is the best option but I wish to test that assumption to see if that is true?
    Edited by: Richard Sherman on Oct 3, 2008 11:53 AM

    Hello,
    we have to use the bulk options with data services and have the same question. Anyone know where a document comparing the two options?
    Thank you very much, Silvia

  • SQL Server image to BLOB

    How can a SQL Server image column (exported by bcp in -c mode as a hexadecimal string) be loaded into a BLOB column with SQL*Loader?
    SQL*Loader gives an error for the HEXTORAW call in the control file generated by OMW (SQL*Loader-309: No SQL string allowed as part of MYDATA field specification):
    load data
    infile 'MYTAB.dat' "str '<er>'"
    into table MYTAB
    fields terminated by '<ec>'
    (MYID ,
    MYDATA CHAR(2000000) "HEXTORAW (:MYDATA)")

    Hello,
    Have you resovled this problem?. How?.
    Thanks,
    Tom

  • SQL Server 2012 Express bulk Insert flat file 1million rows with "" as delimeter

    Hi,
    I wanted to see if anyone can help me out. I am on SQL server 2012 express. I cannot use OPENROWSET because my system is x64 and my Microsoft office suit is x32 (Microsoft.Jet.OLEDB.4.0).
    So I used Import wizard and is not working either. 
    The only thing that let me import this large file, is:
    CREATE TABLE #LOADLARGEFLATFILE
    Column1
    varchar(100), Column2 varchar(100), Column3 varchar(100),
    Column4 nvarchar(max)
    BULK INSERT
    #LOADLARGEFLATFILE
    FROM 'C:\FolderBigFile\LARGEFLATFILE.txt'
    WITH 
    FIRSTROW = 2,
    FIELDTERMINATOR ='\t',
    ROWTERMINATOR ='\n'
    The problem with CREATE TABLE and BULK INSERT is that my flat file comes with text qualifiers - "". Is there a way to prevent the quotes "" from loading in the bulk insert? Below is the data. 
    Column1
    Column2
    Column3
    Column4
    "Socket Adapter"
    8456AB
    $4.25
    "Item - Square Drive Socket Adapter | For "
    "Butt Splice" 
    9586CB
    $14.51
    "Item - Butt Splice"
    "Bleach"
    6589TE
    $27.30
    "Item - Bleach | Size - 96 oz. | Container Type"
    Ed,
    Edwin Lopera

    Hi lgnusLumen,
    According to your description, you use BULK INSERT to import data from a data file to the SQL table. However, to be usable as a data file for bulk import, a CSV file must comply with the following restrictions:
    1. Data fields never contain the field terminator.
    2. Either none or all of the values in a data field are enclosed in quotation marks ("").
    In your data file, the quotes aren't consistent, if you want to prevent the quotes "" from loading in the bulk insert, I recommend you use SQL Server Import and Export Wizard tools in SQL Server Express version. area, it will allow to strip the
    double quote from columns, you can review the following screenshot.
    In other SQL Server version, we can use SQL Server Integration Services (SSIS) to import data from a flat file (.csv) with removing the double quotes. For more information, you can review the following article.
    http://www.mssqltips.com/sqlservertip/1316/strip-double-quotes-from-an-import-file-in-integration-services-ssis/
    In addition, you can create a function to convert a CSV to a usable format for Bulk Insert. It will replace all field-delimiting commas with a new delimiter. You can then use the new field delimiter instead of a comma. For more information, see:
    http://stackoverflow.com/questions/782353/sql-server-bulk-insert-of-csv-file-with-inconsistent-quotes
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Bulk insert into a table

    What is the counter part for sql server BULK insert in Oracle.
    I have gone through an existing thread for the same question Bulk Insert CSV file in Oracle 9i But here it is suggested to read from a file into and external table and then to create my own table reading from external table.
    But I want to read directly from a file to an existing table in my database. How do I achieve this?
    Thank you,
    Praveen.

    Refer to
    http://download.oracle.com/docs/cd/B14117_01/server.101/b10825/ldr_modes.htm#i1008078
    "During Direct Path load through SQL Loader, some constaints and all db triggers are disabled. With the conventional path load method, arrays of rows are inserted with standard SQL INSERT statements—integrity constraints and insert triggers are automatically applied.
    After the rows are loaded and indexes rebuilt, any triggers that were disabled are automatically reenabled. The log file lists all triggers that were disabled for the load. There should not be any errors reenabling triggers."

  • Is there a real comprehensive tutorial out there on BULK INSERT?

    This past week I spent a lot of time learning the nuances of the BULK INSERT method.  I went to many different sites, cobbled together some useful information, and got some great help on this forum too!!  Thanks everyone.  I'm wondering if
    someone here can share a link, or two, that gives really comprehensive coverage of the BULK INSERT method?
    TIA!!
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    My two picks:
    https://www.simple-talk.com/sql/learn-sql-server/bulk-inserts-via-tsql-in-sql-server/
    https://www.simple-talk.com/sql/reporting-services/using-sql-server-integration-services-to-bulk-load-data/

  • LabVIEW & MS SQL SERVER Architect and Developer

    Have keen interest & expert-level know-how on architecting and developing databases geared to automated measurements and control systems that directly interface with LabVIEW.
    Here is specific problem-solving expertise brought to projects:
    Knowledge-Generating & Flexibale Database Schema For Measurements and Control Schema
    In 8 years I have gone through ~15 iterations of database schema and pre-defined queries to finally arrive at guidelines & principles for generating the same for automated control and measurement systems. Re-use of such schema along with the pre-designed database querys has shortened integration time from months to weeks.
    Fast Data Inserts from LabVIEW to Databases
    LabVIEW applications can generate large amounts of data that cannot be inserted fast-enough into databases. However, there are ceratin data insert techniques that can overcome this challenge. MS SQL Server 'Bulk Insert' is a technqiue that I have mastered well that can upload upto 35,000 sample points in one second making databases viable in many automated test and measurement scenarios.
    LabVIEW Real-Time & MS SQL Server Interfacing
    ADO (ActiveX Data-Access Objects) cannot run in LabVIEW real-time systems. However, robust re-usable TCPIP client-server communication modules bridge the gap between LabVIEW Real-Time and MS SQL Server interfacing. These modules run fast enough and can handle complex projects when used in conjunction with LabVIEW FTP and the Bulk-inserts methodology.
    Reporting using Feature Rich Data Grids
    Reporting data with comprehensive search, filter, and hierarchichal organization is accomplished using 3-rd party data grids. Have full mastery in using one advanced data grid for this: Namely: ComponentOne vsFlexgrid 8.0.
    For further info please visit Company web-site at: http://www.mezintel.com
    Regards
    Anthony L.

    Hi:
    I wrote out a reply but could not post because this web site says that my message was more than 10,000 characters and that this exceeds the allowed message length.
    . . . But my message was only 2,300 characters!
    Anyway, I pasted the reply to a word document and have attached here. I have also attached samples of a 'Format File' and a 'Data File'.
    Should you wish to create a Dynamic Bulk insert stored procedure then here it is:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROC [dbo].[AC_Import_SamplesBulkCopy]
        @DataFile nvarchar(150),
        @FormatFile  nvarchar(150),
        @RowsPerBatch nvarchar(100) = '5000'
    AS
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
    SET NOCOUNT ON;
    DECLARE @StrgSQL nvarchar(2000)
    SET @StrgSQL = 'BULK INSERT [LOG_ResultsValues] FROM ''' + @DataFile +
     ''' WITH (FORMATFILE = ''' + @FormatFile + ''', ROWS_PER_BATCH = ' + @RowsPerBatch + ')'
    EXEC (@StrgSQL)
    GO
    Regards
    Anthony L.
    Attachments:
    SQL Bulk Insert Tips.docx ‏16 KB
    SampleFormat.txt ‏2 KB
    SampleData.txt ‏102 KB

  • RE:ora-28500 when trying to insert into SQL Server table

    Hi all!
    I'm getting this when i attempt to insert into my table test in a SQL Server database. As u can see from the select, the database link seems ok. Any ideas plz. Thnx..
    SQL> select "idAges" from test@try2;
    no rows selected
    SQL> insert into test@try2 ("idAges","nARAges","nAPAges") values(10,'','');
    insert into test@try2 ("idAges","nARAges","nAPAges") values(10,'','')
    ERROR at line 1:
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver][SQL
    Server]Cannot insert explicit value for identity column in table 'test' when
    IDENTITY_INSERT is set to OFF. (SQL State: 23000; SQL Code: 544)
    ORA-02063: preceding 2 lines from TRY2

    IDENTITY_INSERT on works only for particular session and for one table. It's not global variable.
    The only idea what I have is to create link from MS Sql to Oracle (right now You have oracle ->ms sql)and then before insert You will set identity_insert on and will run insert.

  • Convert the insert statement of an MS SQL server into an oracle statement

    Hi ,
    The insert statement in the ms sql server is
    INSERT INTO #temp EXEC Procedurename @Id OUTPUT
    where table temp
    CREATE TABLE #temp(
              Id varchar(10),
              FNa varchar(40),
              LNa varchar(40),
              SId varchar(20),
              Aid varchar(20),
              Did varchar(20),
              CCNa varchar(255),
              CCId int,
              ISu char(1),
              IA char(1),
              Dir char(1),
              Ema varchar(60),
              St char(2),
              DId char(3)
    I converted the insert statement like this
    Procedurename(Id);
    LOOP
    FETCH cv_1 INTO v_temp;
    EXIT WHEN cv_1%NOTFOUND;
    INSERT INTO TEMP VALUES v_temp;
    END LOOP;
    CLOSE cv_1;
    But i am receiving PL/SQL: ORA-00947: not enough values
    Can anyone help on this?
    Thanks

    1) Are you sure that you even need a temp table? Fetching all the rows from a cursor 1-by-1 and then inserting them into a temp table (I'm assuming the Oracle table TEMP is declared as a global temporary table) would seem rather unusual and most likely pointless. In Oracle, readers don't block writers, so there is generally no need to use temp tables to hold intermediate results.
    2) If you do need to store a set of results into a table, it's going to be more efficient to do this in a single SQL statement rather than using a cursor. Something like
    INSERT INTO my_table ( <<list of columns>> )
      SELECT <<list of columns>>
        FROM <<other tables>>
       WHERE <<some conditions>>The SELECT part of the statement here is likely whatever SQL you use in declaring the cursor.
    Justin

  • 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.

  • Insert to XE from sql server 2005 ...

    Hi,
    is it possible to create a trigger on Sql Server 2005 to insert a row to Oracle XE ?
    I want to create a update/insert trigger on sql server 2005 which will insert the data into a Oracle XE table.
    I have a Linked Servers in Sql Server to Oracle XE and this link works with simple sql statement from sql server like :
    INSERT INTO [NEW_OR]..[Adam_user].[DUMMY] (AA) VALUES('Dummy String Data')
    But the same statement does not work when in trigger. the following error occurs in Sql Server 2005...
    Msg 8501, Level 16, State 3, Procedure deneme, Line 5
    MSDTC on server 'Adam_user' is unavailable.
    Any suggestions?
    Thanks in advance.....
    Adam

    Here is the answer...
    May be useful for someone who needs the same solution ...
    The Distributed Transaction Coordinator service must be start on windows to accomplish the transaction ...
    For this:
    (on windows)
    START > SETTINGS > CONTROL PANEL > ADMINISTRATIVE TOOLS > SERVICES. Find the service called 'Distributed Transaction Coordinator' and RIGHT CLICK (on it and select) > Start.

Maybe you are looking for

  • IPod touch 4 requires MAJOR system overhaul.  Major Disappointment!!!!!!!

    Folks, I have a nice iMac that's about 3 years old.  Bought about 2 months before snow leopard, so I've been using 10.4 just fine until recently.  Daughter's iPod bit the dust, and she got a new iPod touch the Fourth.  What a disaster this whole expe

  • Windows 7 Laptop to external LCD monitor show low resolution

    Hello, I'm connecting my laptop to external LCD 1920*1080. When Extend the display, each screen works with its full resolution allowed (Laptop has lower than 1920*1080 and the LCD works with resolution of 1920*1080), but when duplicate the display, t

  • Is it possible to unload a class?

    Suppose I take a classloader and load a class. Then I set my classloader to null and get rid of any objects of it that I've instantiated. Can that class be garbage collected? I'm thinking that it probably isn't possible. Even if you can get rid of al

  • How do I enable javascript if there is no option to enable javascript - follow-up

    I have read the solution on about:config solution in the original post, but when I when there, I found Java is already enabled - the default configuration. I am running Noscript, yet I am prompted on virtually every page, to allow or forbid scripting

  • Laptop to TV

    I have a new LG 3D LCD TV and a Toshiba laptop.  I want to connect my laptop to TV so I can watch Netflix, I've got the 15 pin connector and have video displayed on the TV no problem.  I don't know how to get the audio off the laptop and onto the TV