472,780 Members | 1,364 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

Bulk insert into views that select from table on remote server

Hi all,

We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the servers using
sp_addlinkedserver on both database servers.

When I call the Commit API of oledb I get the following error:

Error state: 1, Severity: 19, Server: TST-PROC22, Line#: 1, msg:
SqlDumpExceptio
nHandler: Process 66 generated fatal exception c0000005
EXCEPTION_ACCESS_VIOLATI
ON. SQL Server is terminating this process.

I would like to know if we can bulk insert rows into a view that
accesses a table on the remote server using the "bulk insert" or bcp
command. I tried a small test through SQL Query Analyser to use "bulk
insert" on a such a view.

The test that I performed was the following:

On database server 1 :

create table iqbal (var1 int, var2 int)

On database server 2 (remote server):

create view iqbal as select var1,var2 from
[DBServer1].[SomeDB].[dbo].[iqbal]

set xact_abort on
bulk insert iqbal from '\\Machine\Iqbal\iqbaldata.txt'

The bulk insert operation failed with the following error message:

[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.

Connection Broken

The file iqbaldata.txt contents were :
1 1
2 2
3 3
If the table that the view references is on the same server then we
are able to bulk insert successfully.
Is there a way by which I should be able to bulk insert rows into a
view that selects from a table on a remote server. If not then could
anyone suggest a workaround. I would actually like to know some
workaround to get the code working using OLEDB. Due to unavoidable
reasons I cannot output the records to the file and then use bcp to
bulk insert the records in the remote table. I need to have some way
of doing it using OLEDB.

Thanks in advance
Iqbal
Jul 20 '05 #1
7 11954
iqbal (iq******@hotmail.com) writes:
We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the servers using
sp_addlinkedserver on both database servers.

When I call the Commit API of oledb I get the following error:

Error state: 1, Severity: 19, Server: TST-PROC22, Line#: 1, msg:
SqlDumpExceptio
nHandler: Process 66 generated fatal exception c0000005
EXCEPTION_ACCESS_VIOLATI
ON. SQL Server is terminating this process.

I would like to know if we can bulk insert rows into a view that
accesses a table on the remote server using the "bulk insert" or bcp
command. I tried a small test through SQL Query Analyser to use "bulk
insert" on a such a view.


My initial reaction would be that "this is not possible", since it
just sounds far out. Then again, would that be a case, you should
get a civilized error message.

What I can to, is to use my contacts at Microsoft, to inquire the
status. But I would not really expect any positive answer.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
iq******@hotmail.com (iqbal) wrote in message news:<3b**************************@posting.google. com>...
Hi all,

We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the servers using
sp_addlinkedserver on both database servers. [cut]
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.

Iqbal,
Do you have your server enabled for data access?
You can run

EXEC sp_serveroption 'DBServer1', 'data access', 'ON'
HTH,
Igor
Jul 20 '05 #3
ig*****@yahoo.com (Igor Raytsin) wrote in message news:<a7**************************@posting.google. com>...
iq******@hotmail.com (iqbal) wrote in message news:<3b**************************@posting.google. com>...
Hi all,

We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the servers using
sp_addlinkedserver on both database servers.

[cut]

[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.

Iqbal,
Do you have your server enabled for data access?
You can run

EXEC sp_serveroption 'DBServer1', 'data access', 'ON'
HTH,
Igor


Didn't work :(
But what you can do is

SELECT * INTO local_iqbal
FROM iqbal
where 1=2
go

bulk insert local_iqbal from '\\Machine\Iqbal\iqbaldata.txt'
go

INSERT iqbal
SELECT *
FROM local_iqbal
go

HTH,
Igor
Jul 20 '05 #4
ig*****@yahoo.com (Igor Raytsin) wrote in message news:<a7**************************@posting.google. com>...
iq******@hotmail.com (iqbal) wrote in message news:<3b**************************@posting.google. com>...
Hi all,

We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the servers using
sp_addlinkedserver on both database servers.

[cut]

[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.

Iqbal,
Do you have your server enabled for data access?
You can run

EXEC sp_serveroption 'DBServer1', 'data access', 'ON'
HTH,
Igor


Hi Igor,

I executed the "EXEC sp_serveroption 'ServerName', 'data access',
'ON'" command but I still the same error message.

As a work-around for running "bulk insert" command successfully I
created an "instead of insert" trigger on the view that inserts the
data into the table on the remote server. The trigger was:

create trigger iqbal_trig on iqbal instead of insert as
begin
insert into [ps0070].[bl001].[dbo].iqbal select * from inserted
end
I then executed the "bulk insert" command giving it the hint as
follows:

set xact_abort on
bulk insert iqbal from '\\ps0070\RevenueScience\iqbaldata.txt' with
(FIRE_TRIGGERS)

It worked. The remote table was populated with the correct data.

Is there a way by which I can provide hints while bulk inserting using
oledb? I want to achieve this behaviour in the application that uses
oledb. Does oledb by default execute triggers on the table/view by
default? I'm sure "bulk insert" command does not do it by default.

Thanks,
Iqbal
Jul 20 '05 #5
iqbal (iq******@hotmail.com) writes:
As a work-around for running "bulk insert" command successfully I
created an "instead of insert" trigger on the view that inserts the
data into the table on the remote server. The trigger was:

create trigger iqbal_trig on iqbal instead of insert as
begin
insert into [ps0070].[bl001].[dbo].iqbal select * from inserted
end
I then executed the "bulk insert" command giving it the hint as
follows:

set xact_abort on
bulk insert iqbal from '\\ps0070\RevenueScience\iqbaldata.txt' with
(FIRE_TRIGGERS)

It worked. The remote table was populated with the correct data.
Great to hear that got it working. Now, it does not sound really
performant, but if it was performance you were after, you should
probably bulk insert into the remote table directly.
Is there a way by which I can provide hints while bulk inserting using
oledb? I want to achieve this behaviour in the application that uses
oledb. Does oledb by default execute triggers on the table/view by
default? I'm sure "bulk insert" command does not do it by default.


The property SSPROP_FASTLOADOPTIONS permits you specify various options
for BULK INSERT. Books Online starts the description with saying:

Description: This property is the same as the -h "hint[,...n]" option
of the bcp utility. The following string(s) can be used as option(s) in
the bulk copying of data into a table.

So far, so good, because FIRE_TRIGGERS is among those hints. But! On
the page IRowsetFastLoad Rowsets where I found SSPROP_FASTLOADOPTIONS,
all hints but FIRE_TRIGGERS are there. My guess is that this is a
documentation error, so I would recommend you to try to set
SSPROP_FASTLOADOPTIONS to FIRE_TRIGGERS and set what happens.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #6
It seems like a bug in MS SQL 2000 (or MS DTC?).

I was able to that (bulk insert into view which points to a table on
linked server) from SQL 7 to SQL 2000 without any problem.
Igor

iq******@hotmail.com (iqbal) wrote in message news:<3b**************************@posting.google. com>...
Hi all,

We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the servers using
sp_addlinkedserver on both database servers.

When I call the Commit API of oledb I get the following error:

Error state: 1, Severity: 19, Server: TST-PROC22, Line#: 1, msg:
SqlDumpExceptio
nHandler: Process 66 generated fatal exception c0000005
EXCEPTION_ACCESS_VIOLATI
ON. SQL Server is terminating this process.

I would like to know if we can bulk insert rows into a view that
accesses a table on the remote server using the "bulk insert" or bcp
command. I tried a small test through SQL Query Analyser to use "bulk
insert" on a such a view.

The test that I performed was the following:

On database server 1 :

create table iqbal (var1 int, var2 int)

On database server 2 (remote server):

create view iqbal as select var1,var2 from
[DBServer1].[SomeDB].[dbo].[iqbal]

set xact_abort on
bulk insert iqbal from '\\Machine\Iqbal\iqbaldata.txt'

The bulk insert operation failed with the following error message:

[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.

Connection Broken

The file iqbaldata.txt contents were :
1 1
2 2
3 3
If the table that the view references is on the same server then we
are able to bulk insert successfully.
Is there a way by which I should be able to bulk insert rows into a
view that selects from a table on a remote server. If not then could
anyone suggest a workaround. I would actually like to know some
workaround to get the code working using OLEDB. Due to unavoidable
reasons I cannot output the records to the file and then use bcp to
bulk insert the records in the remote table. I need to have some way
of doing it using OLEDB.

Thanks in advance
Iqbal

Jul 20 '05 #7
To resolve the issue I have bulk inserted rows into a temporary table
on the server. I then insert these rows into the view (that selects
from a remote table) as was also suggested by Igor.

This workaround is working fine. Though it is not a highly efficient
solution.

ig*****@yahoo.com (Igor Raytsin) wrote in message news:<a7**************************@posting.google. com>...
It seems like a bug in MS SQL 2000 (or MS DTC?).

I was able to that (bulk insert into view which points to a table on
linked server) from SQL 7 to SQL 2000 without any problem.
Igor

iq******@hotmail.com (iqbal) wrote in message news:<3b**************************@posting.google. com>...
Hi all,

We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the servers using
sp_addlinkedserver on both database servers.

When I call the Commit API of oledb I get the following error:

Error state: 1, Severity: 19, Server: TST-PROC22, Line#: 1, msg:
SqlDumpExceptio
nHandler: Process 66 generated fatal exception c0000005
EXCEPTION_ACCESS_VIOLATI
ON. SQL Server is terminating this process.

I would like to know if we can bulk insert rows into a view that
accesses a table on the remote server using the "bulk insert" or bcp
command. I tried a small test through SQL Query Analyser to use "bulk
insert" on a such a view.

The test that I performed was the following:

On database server 1 :

create table iqbal (var1 int, var2 int)

On database server 2 (remote server):

create view iqbal as select var1,var2 from
[DBServer1].[SomeDB].[dbo].[iqbal]

set xact_abort on
bulk insert iqbal from '\\Machine\Iqbal\iqbaldata.txt'

The bulk insert operation failed with the following error message:

[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.

Connection Broken

The file iqbaldata.txt contents were :
1 1
2 2
3 3
If the table that the view references is on the same server then we
are able to bulk insert successfully.
Is there a way by which I should be able to bulk insert rows into a
view that selects from a table on a remote server. If not then could
anyone suggest a workaround. I would actually like to know some
workaround to get the code working using OLEDB. Due to unavoidable
reasons I cannot output the records to the file and then use bcp to
bulk insert the records in the remote table. I need to have some way
of doing it using OLEDB.

Thanks in advance
Iqbal

Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: pk | last post by:
Sorry for the piece-by-piece nature of this post, I moved it from a dormant group to this one and it was 3 separate posts in the other group. Anyway... I'm trying to bulk insert a text file of...
2
by: Mike Husler | last post by:
We have created CSV files on HPUX 11.0 and transferred them via ASCII ftp to our SQL Server machine file store to load large amounts for data using the BULK INSERT command. This is the command: ...
9
by: adi | last post by:
Hi all, Hope there is a quick fix for this: I am inserting data from one table to another on the same DB. The insert is pretty simple as in: insert into datatable(field1, field2, field3)...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
2
by: Zarrin | last post by:
Hello, I read several articles of newsgroup about the bulk delete, and I found one way is to: -create a temporary table with all constraints of original table -insert rows to be retained into...
2
by: Ted | last post by:
I have BULK INSERT T-SQL statements that work for all of my basic data tables except for one. Here is the problem statement (with obvious replacement of irrelevant path info): BULK INSERT...
2
by: nano | last post by:
Does sql server have a way to handle errors in a sproc which would allow one to insert rows, ignoring rows which would create a duplicate key violation? I know if one loops one can handle the error...
0
by: diane | last post by:
Just trying to upsize using VFP 9 with SQL 2005 using VFP remote views. One in particular keeps coming up and saying Cannot insert the value NULL into column, when I really don't think I am...
3
by: akdemirc | last post by:
i have a problem with large data import to a db in sql server.. Actually i have an application that collects data from an environment and dispatches this data to different csv files for sql server to...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.