SQL Server 2000 RPC inside transaction - sql-server

I have created a linked server to from SQL Server 2000 to SQL Server 2008 R2.
And I am making RPC call inside a stored procedures as below.
--successful without transaction
execute sql2008server.DBName.dbo.sp_in_sql2008 #param1...,#paramn
-- end successful without transaction
This works successfully, however the same RPC call fails from with in a Transaction as shown below.
-- Below call fails
BEGIN TRANSACTION 'someTran'
--some lines of statements
execute sql2008server.DBName.dbo.sp_in_sql2008 #param1...,#paramn
END
The remote stored procedure in SQL Server 2008 has a transaction inside it.
So SQL Server 2000 doesn't allow nested transaction in RPC?
Or it doesn't allow RPC inside a transaction at all?
Any help is appreciated.
Thanks in advance,
Ramesh.

Related

How to determine where is opened transaction?

I have a c# utility which executes scripts.
If I run the app on SQL Server in LAN - it works fine.
If I run it on SQL Server in AWS RDS I receive an error:
it executes stored procedure which drops FT indexes and created them again.
The executenonquery returns an error
DROP FULLTEXT INDEX statement cannot be used inside a user transaction.
I have added to the sp
print ##TRANCOUNT
When I run the sp in SSMS for db in LAN or RDS it returns 0
When my app exectes sp on db in RDS it returns 1.
Also, how to check SQLConnection executes command and has opened transaction?
I really do not understand how to fix the problem. Any help appreciated

How do I automatically fire a (remote) stored procedure in SQL Server when connecting to a remote server?

The specific issue is that I want a SQL Server to connect to an Oracle database and the Oracle database has a Virtual Private Database configured. I need to execute a static stored procedure to enable the VPD to see data. How can I configure SQL Server to fire a stored procedure upon connecting to a remote database? I figure if I can fire a local stored procedure, I can put the remote stored procedure call inside of that. The key is, I need the SQL Server to fire this as soon as it is done connecting to the remote database and before it tries to pass any other queries to it. I'm trying to avoid making the applications do it explicitly.
SQL Server does not offer a solution to my problem.
However, you can setup the service account to have a logon trigger to execute what is needed.
Create Trigger My_User.Logon_Trigger_Name
AFTER LOGON
ON SCHEMA
WHEN (USER = 'MY_USER')
BEGIN
--Do Stuff Here.
NULL;
EXCEPTION
WHEN OTHERS THEN
NULL; --Consume errors so you can still log on.
END;

Data visibility between linked server

Please consider the following situation
I have Prod instance of SQL server 2012
Also Archive instance of SQL server express 2012
Prod sees Archive as linked server and is able to write data with similar query from some .net code that creates a transaction and the transaction is committed at the end.
insert into <ArchiveServer>.<database>.<schema>.<table>
Select * from <ProductionServer>.<database>.<schema>.<table> Where <some conditions>
Now after the transaction finishes I am able to execute the following query
select count(1) from <ArchiveServer>.<database>.<schema>.<table>
and it returns correct number of records in the context of production server.
Same query
select count(1) from <database>.<schema>.<table>
in the context of Archive server returned 0 records.
What might be the problem? I am out of clues.
Thanks

Timeout for long-running queries with RODBC & MS SQL Server

I have to run an SQL query that iterates cursor over a larger table (MS SQL Server 2014). It would be rather difficult not to use a cursor for this particular purpose.
The cursor-related code is kept in a stored procedure. R only evaluated EXEC dbo.do_something. EXEC dbo.do_something works as expected when running the code from MS SQL Management Studio. When I run it via RODBC, the query aborts without error message after 30 secs. I guess this is the value of "Connection Timeout".
What options do I have to make the query work with R?
It seems the answer to my particular problem is rather simple: Add SET NOCOUNT ON to the proc definition.

Starting new transaction in MS SQL fails

I am stuck on the following problem. Starting a new transaction after calling a stored procedure gives me "SQL Server Native Client 11.0][SQL Server]New transaction is not allowed because there are other threads running in the session." If I remove the call of that procedure all work out just fine.
The procedure does not start any transaction only reads data.
Some people suggest enabling MultipleActiveResultSets http://php.net/manual/de/ref.pdo-sqlsrv.connection.php but that does not solve the problem.
So the question is how calling a stored procedure may affect starting new transaction in my case.
There is the proc http://pastie.org/9718368

Resources