Showing posts with label triggers. Show all posts
Showing posts with label triggers. Show all posts

Wednesday, March 21, 2012

servers and Triggers...

I have a read many of the threads that have to do with linked servers and
have not found out how to over come the 7391 error. I have setup up
everything using both openrowset and openquery and the same error comes back
when I have a trigger setup to update a Pervasive table from MSSQL. However
if I run those queries in the query anaylzer they run fine.
Here is the openrowset query:
update openrowset('MSDASQL','DSN=MAXDAT','select * from "Customer Master"')
set UDFREF_23='ABC' where custid_23='2400047'
and here is the openquery query:
update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
I have a trigger set up to run the update queries but it fails with the 7391
error.
Why would they work fine in the query analyzer and not from a MSSQL trigger
or stored procedure?
Thank you for any help.Because in Query Analyzer, depending on the environment parameters, you
might not be illiciting a Distributed Transaction. However, in a stored
procedure, and most assuradely a trigger, you will have to begin a
distributed transaction unless you explicitly override the creation of one.
Sincerely,
Anthony Thomas
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:82AD4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...
I have a read many of the threads that have to do with linked servers and
have not found out how to over come the 7391 error. I have setup up
everything using both openrowset and openquery and the same error comes back
when I have a trigger setup to update a Pervasive table from MSSQL. However
if I run those queries in the query anaylzer they run fine.
Here is the openrowset query:
update openrowset('MSDASQL','DSN=MAXDAT','select * from "Customer Master"')
set UDFREF_23='ABC' where custid_23='2400047'
and here is the openquery query:
update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
I have a trigger set up to run the update queries but it fails with the 7391
error.
Why would they work fine in the query analyzer and not from a MSSQL trigger
or stored procedure?
Thank you for any help.|||Anthony:
So what I use to override the creation of one?
MCR
"AnthonyThomas" wrote:
> Because in Query Analyzer, depending on the environment parameters, you
> might not be illiciting a Distributed Transaction. However, in a stored
> procedure, and most assuradely a trigger, you will have to begin a
> distributed transaction unless you explicitly override the creation of one.
> Sincerely,
>
> Anthony Thomas
>
> --
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:82AD4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...
> I have a read many of the threads that have to do with linked servers and
> have not found out how to over come the 7391 error. I have setup up
> everything using both openrowset and openquery and the same error comes back
> when I have a trigger setup to update a Pervasive table from MSSQL. However
> if I run those queries in the query anaylzer they run fine.
> Here is the openrowset query:
> update openrowset('MSDASQL','DSN=MAXDAT','select * from "Customer Master"')
> set UDFREF_23='ABC' where custid_23='2400047'
>
> and here is the openquery query:
> update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
> Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
> I have a trigger set up to run the update queries but it fails with the 7391
> error.
> Why would they work fine in the query analyzer and not from a MSSQL trigger
> or stored procedure?
> Thank you for any help.
>
>|||This is a multi-part message in MIME format.
--=_NextPart_000_07D2_01C4F23F.A803CFA0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
Explicitly set your environment parameters:
SET XACT_ABORT OFF
SET IMPLICIT_TRANSACTIONS OFF
There is another one for remote procedure transactions that you can set off
as well. You'll need to look it up.
Also, make sure you do not create any locks on the remote read. Depending
on the platform, you need to set READ UNCOMMITTED isolation levels on your
sources.
The other option is to verify that the linked_server is configured properly
for distributed transactions.
However, I suspect that this worked in QA for you because you did not have
IMPLICIT_TRANSACTIONS set on. These are configurable from the interface
under Connection Properties or Current Query Properties.
Sincerely,
Anthony Thomas
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:6281615A-F7FA-4EAB-BFEA-D0E92C52C3EF@.microsoft.com...
Anthony:
So what I use to override the creation of one?
MCR
"AnthonyThomas" wrote:
> Because in Query Analyzer, depending on the environment parameters, you
> might not be illiciting a Distributed Transaction. However, in a stored
> procedure, and most assuradely a trigger, you will have to begin a
> distributed transaction unless you explicitly override the creation of
one.
>
> Sincerely,
>
>
> Anthony Thomas
>
>
> --
>
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:82AD4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...
> I have a read many of the threads that have to do with linked servers
and
> have not found out how to over come the 7391 error. I have setup up
> everything using both openrowset and openquery and the same error comes
back
> when I have a trigger setup to update a Pervasive table from MSSQL.
However
> if I run those queries in the query anaylzer they run fine.
>
> Here is the openrowset query:
> update openrowset('MSDASQL','DSN=MAXDAT','select * from "Customer
Master"')
> set UDFREF_23='ABC' where custid_23='2400047'
>
>
> and here is the openquery query:
> update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
> Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
>
> I have a trigger set up to run the update queries but it fails with the
7391
> error.
>
> Why would they work fine in the query analyzer and not from a MSSQL
trigger
> or stored procedure?
>
> Thank you for any help.
>
>
>
--=_NextPart_000_07D2_01C4F23F.A803CFA0
Content-Type: text/html;
charset="Utf-8"
Content-Transfer-Encoding: quoted-printable
=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Explicitly set your environment parameters:
SET XACT_ABORT OFF
SET IMPLICIT_TRANSACTIONS =OFF
There is another one for remote =procedure transactions that you can set off as well. You'll need to look it up.
Also, make sure you do not create any =locks on the remote read. Depending on the platform, you need to set READ UNCOMMITTED isolation levels on your sources.
The other option is to verify that =the linked_server is configured properly for distributed =transactions.
However, I suspect that this worked =in QA for you because you did not have IMPLICIT_TRANSACTIONS set on. These are configurable from the interface under Connection Properties or Current =Query Properties.
Sincerely,
Anthony Thomas
--
"Mike" wrote in message news:628=1615A-F7FA-4EAB-BFEA-D0E92C52C3EF@.microsoft.com...Anthony:So what I use to override the creation of one? =MCR"AnthonyThomas" wrote:> Because in Query Analyzer, depending on the =environment parameters, you> might not be illiciting a Distributed Transaction. However, in a stored> procedure, and most =assuradely a trigger, you will have to begin a> distributed transaction =unless you explicitly override the creation of one.> > =Sincerely,> > > Anthony Thomas> > > -- > = > "Mike" wrote in message> news:82A=D4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...> I have a read many of the threads that have to do with linked servers and> have not found out how to over come the 7391 error. I have =setup up> everything using both openrowset and openquery and the same =error comes back> when I have a trigger setup to update a Pervasive =table from MSSQL. However> if I run those queries in the query =anaylzer they run fine.> > Here is the openrowset query:> =update openrowset('MSDASQL','DSN=3DMAXDAT','select * from "Customer =Master"')> set UDFREF_23=3D'ABC' where custid_23=3D'2400047'> > => and here is the openquery query:> update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer> Master"') set =UDFREF_23=3D'ZZZ' where custid_23=3D'2400047'> > I have a trigger set up =to run the update queries but it fails with the 7391> error.> => Why would they work fine in the query analyzer and not from a MSSQL trigger> or stored procedure?> > Thank you for =any help.> > >

--=_NextPart_000_07D2_01C4F23F.A803CFA0--

servers and Triggers...

I have a read many of the threads that have to do with linked servers and
have not found out how to over come the 7391 error. I have setup up
everything using both openrowset and openquery and the same error comes back
when I have a trigger setup to update a Pervasive table from MSSQL. However
if I run those queries in the query anaylzer they run fine.
Here is the openrowset query:
update openrowset('MSDASQL','DSN=MAXDAT','select * from "Customer Master"')
set UDFREF_23='ABC' where custid_23='2400047'
and here is the openquery query:
update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
I have a trigger set up to run the update queries but it fails with the 7391
error.
Why would they work fine in the query analyzer and not from a MSSQL trigger
or stored procedure?
Thank you for any help.
Because in Query Analyzer, depending on the environment parameters, you
might not be illiciting a Distributed Transaction. However, in a stored
procedure, and most assuradely a trigger, you will have to begin a
distributed transaction unless you explicitly override the creation of one.
Sincerely,
Anthony Thomas

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:82AD4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...
I have a read many of the threads that have to do with linked servers and
have not found out how to over come the 7391 error. I have setup up
everything using both openrowset and openquery and the same error comes back
when I have a trigger setup to update a Pervasive table from MSSQL. However
if I run those queries in the query anaylzer they run fine.
Here is the openrowset query:
update openrowset('MSDASQL','DSN=MAXDAT','select * from "Customer Master"')
set UDFREF_23='ABC' where custid_23='2400047'
and here is the openquery query:
update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
I have a trigger set up to run the update queries but it fails with the 7391
error.
Why would they work fine in the query analyzer and not from a MSSQL trigger
or stored procedure?
Thank you for any help.
|||Anthony:
So what I use to override the creation of one?
MCR
"AnthonyThomas" wrote:

> Because in Query Analyzer, depending on the environment parameters, you
> might not be illiciting a Distributed Transaction. However, in a stored
> procedure, and most assuradely a trigger, you will have to begin a
> distributed transaction unless you explicitly override the creation of one.
> Sincerely,
>
> Anthony Thomas
>
> --
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:82AD4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...
> I have a read many of the threads that have to do with linked servers and
> have not found out how to over come the 7391 error. I have setup up
> everything using both openrowset and openquery and the same error comes back
> when I have a trigger setup to update a Pervasive table from MSSQL. However
> if I run those queries in the query anaylzer they run fine.
> Here is the openrowset query:
> update openrowset('MSDASQL','DSN=MAXDAT','select * from "Customer Master"')
> set UDFREF_23='ABC' where custid_23='2400047'
>
> and here is the openquery query:
> update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
> Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
> I have a trigger set up to run the update queries but it fails with the 7391
> error.
> Why would they work fine in the query analyzer and not from a MSSQL trigger
> or stored procedure?
> Thank you for any help.
>
>
|||Explicitly set your environment parameters:
SET XACT_ABORT OFF
SET IMPLICIT_TRANSACTIONS OFF
There is another one for remote procedure transactions that you can set off
as well. You'll need to look it up.
Also, make sure you do not create any locks on the remote read. Depending
on the platform, you need to set READ UNCOMMITTED isolation levels on your
sources.
The other option is to verify that the linked_server is configured properly
for distributed transactions.
However, I suspect that this worked in QA for you because you did not have
IMPLICIT_TRANSACTIONS set on. These are configurable from the interface
under Connection Properties or Current Query Properties.
Sincerely,
Anthony Thomas

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:6281615A-F7FA-4EAB-BFEA-D0E92C52C3EF@.microsoft.com...
Anthony:
So what I use to override the creation of one?
MCR
"AnthonyThomas" wrote:

> Because in Query Analyzer, depending on the environment parameters, you
> might not be illiciting a Distributed Transaction. However, in a stored
> procedure, and most assuradely a trigger, you will have to begin a
> distributed transaction unless you explicitly override the creation of
one.
> Sincerely,
>
> Anthony Thomas
>
> --
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:82AD4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...
> I have a read many of the threads that have to do with linked servers
and
> have not found out how to over come the 7391 error. I have setup up
> everything using both openrowset and openquery and the same error comes
back
> when I have a trigger setup to update a Pervasive table from MSSQL.
However
> if I run those queries in the query anaylzer they run fine.
> Here is the openrowset query:
> update openrowset('MSDASQL','DSN=MAXDAT','select * from "Customer
Master"')
> set UDFREF_23='ABC' where custid_23='2400047'
>
> and here is the openquery query:
> update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
> Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
> I have a trigger set up to run the update queries but it fails with the
7391
> error.
> Why would they work fine in the query analyzer and not from a MSSQL
trigger
> or stored procedure?
> Thank you for any help.
>
>

servers and Triggers...

I have a read many of the threads that have to do with linked servers and
have not found out how to over come the 7391 error. I have setup up
everything using both openrowset and openquery and the same error comes back
when I have a trigger setup to update a Pervasive table from MSSQL. However
if I run those queries in the query anaylzer they run fine.
Here is the openrowset query:
update openrowset('MSDASQL','DSN=MAXDAT','selec
t * from "Customer Master"')
set UDFREF_23='ABC' where custid_23='2400047'
and here is the openquery query:
update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
I have a trigger set up to run the update queries but it fails with the 7391
error.
Why would they work fine in the query analyzer and not from a MSSQL trigger
or stored procedure?
Thank you for any help.Because in Query Analyzer, depending on the environment parameters, you
might not be illiciting a Distributed Transaction. However, in a stored
procedure, and most assuradely a trigger, you will have to begin a
distributed transaction unless you explicitly override the creation of one.
Sincerely,
Anthony Thomas
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:82AD4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...
I have a read many of the threads that have to do with linked servers and
have not found out how to over come the 7391 error. I have setup up
everything using both openrowset and openquery and the same error comes back
when I have a trigger setup to update a Pervasive table from MSSQL. However
if I run those queries in the query anaylzer they run fine.
Here is the openrowset query:
update openrowset('MSDASQL','DSN=MAXDAT','selec
t * from "Customer Master"')
set UDFREF_23='ABC' where custid_23='2400047'
and here is the openquery query:
update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
I have a trigger set up to run the update queries but it fails with the 7391
error.
Why would they work fine in the query analyzer and not from a MSSQL trigger
or stored procedure?
Thank you for any help.|||Anthony:
So what I use to override the creation of one?
MCR
"AnthonyThomas" wrote:

> Because in Query Analyzer, depending on the environment parameters, you
> might not be illiciting a Distributed Transaction. However, in a stored
> procedure, and most assuradely a trigger, you will have to begin a
> distributed transaction unless you explicitly override the creation of one
.
> Sincerely,
>
> Anthony Thomas
>
> --
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:82AD4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...
> I have a read many of the threads that have to do with linked servers and
> have not found out how to over come the 7391 error. I have setup up
> everything using both openrowset and openquery and the same error comes ba
ck
> when I have a trigger setup to update a Pervasive table from MSSQL. Howeve
r
> if I run those queries in the query anaylzer they run fine.
> Here is the openrowset query:
> update openrowset('MSDASQL','DSN=MAXDAT','selec
t * from "Customer Master"'
)
> set UDFREF_23='ABC' where custid_23='2400047'
>
> and here is the openquery query:
> update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
> Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
> I have a trigger set up to run the update queries but it fails with the 73
91
> error.
> Why would they work fine in the query analyzer and not from a MSSQL trigge
r
> or stored procedure?
> Thank you for any help.
>
>|||Explicitly set your environment parameters:
SET XACT_ABORT OFF
SET IMPLICIT_TRANSACTIONS OFF
There is another one for remote procedure transactions that you can set off
as well. You'll need to look it up.
Also, make sure you do not create any locks on the remote read. Depending
on the platform, you need to set READ UNCOMMITTED isolation levels on your
sources.
The other option is to verify that the linked_server is configured properly
for distributed transactions.
However, I suspect that this worked in QA for you because you did not have
IMPLICIT_TRANSACTIONS set on. These are configurable from the interface
under Connection Properties or Current Query Properties.
Sincerely,
Anthony Thomas
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:6281615A-F7FA-4EAB-BFEA-D0E92C52C3EF@.microsoft.com...
Anthony:
So what I use to override the creation of one?
MCR
"AnthonyThomas" wrote:

> Because in Query Analyzer, depending on the environment parameters, you
> might not be illiciting a Distributed Transaction. However, in a stored
> procedure, and most assuradely a trigger, you will have to begin a
> distributed transaction unless you explicitly override the creation of
one.
> Sincerely,
>
> Anthony Thomas
>
> --
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:82AD4E62-5FDE-4EB8-B905-4D3D5C5698D7@.microsoft.com...
> I have a read many of the threads that have to do with linked servers
and
> have not found out how to over come the 7391 error. I have setup up
> everything using both openrowset and openquery and the same error comes
back
> when I have a trigger setup to update a Pervasive table from MSSQL.
However
> if I run those queries in the query anaylzer they run fine.
> Here is the openrowset query:
> update openrowset('MSDASQL','DSN=MAXDAT','selec
t * from "Customer
Master"')
> set UDFREF_23='ABC' where custid_23='2400047'
>
> and here is the openquery query:
> update openquery(MAXTEST,'select custid_23, udfref_23 from "Customer
> Master"') set UDFREF_23='ZZZ' where custid_23='2400047'
> I have a trigger set up to run the update queries but it fails with the
7391
> error.
> Why would they work fine in the query analyzer and not from a MSSQL
trigger
> or stored procedure?
> Thank you for any help.
>
>

servers and Triggers

I have two servers one on SQL Server 2000 one on SQL Server 7
I have setup the two servers so that they are linked and have added appropriate logins.
How it works is a record is inserted into a database on SQL 2000 which has a trigger on it that send the record to a stored procedure on the SQL 7 server, from there this places the record into a table, which calls a trigger. Now this all works fine when I use the query analyser however when I don't use it, the record does not get inserted anywhere. Now I have stepped through it and it works up until the last trigger, if I remove that everything works fine. However the code in this trigger works fine, as when I use the quuery analyser everything works just as it should.

Does anyone have any suggestions as to how I can get this to work?

Thanks :-)Look into heterogenous queries in BOL.|||Make sure the last trigger is compiled using requirements of heterogeneous queries.

Friday, March 9, 2012

server, stored procedure and Views (Heterogeneous Errors)

I have linked to another SQL Instance, created a view and a stored procedure
to access it. This works great through MS Query, but not via SQL Triggers or
through calling through code in another application.
The views and sprocs create without errors, it's only when running them.
Any Ideas?Ray
Can you show us how you call the statemnet?
"Ray" <rayc@.rsc.com> wrote in message
news:FEEE24DA-571B-4C46-887B-33D4F772553E@.microsoft.com...
>I have linked to another SQL Instance, created a view and a stored
>procedure
> to access it. This works great through MS Query, but not via SQL Triggers
> or
> through calling through code in another application.
> The views and sprocs create without errors, it's only when running them.
> Any Ideas?|||you will have to use the four part naming convention
linkedservername.database.owner.object
thanks,
Jose de Jesus Jr. Mcp,Mcdba
Data Architect
Sykes Asia (Manila philippines)
MCP #2324787
"Ray" wrote:

> I have linked to another SQL Instance, created a view and a stored procedu
re
> to access it. This works great through MS Query, but not via SQL Triggers
or
> through calling through code in another application.
> The views and sprocs create without errors, it's only when running them.
> Any Ideas?