"Cannot process the object" after release update from AS400 iseries i5 from V6R1 to V7R1 - sql

this statments work under V6R1 but not under V7R1 with an ODBC linked server in an SQL Server 2012
select * from AS400.AS400.LIB.TAB
SQL Managment Studio thrown the error:
Cannot process the object "AS400.LIB.TAB". The OLE DB provider "IBMDASQL" for linked server "AS400" indicates that either the object has no columns or the current user does not have permissions on that object. [SQLSTATE 42000] (Error 7357). The step failed.
Do somebody have an idea to fix this problem?
regards Jo

EXEC ('SELECT * FROM LIB.TAB') AT AS400
and if calling a stored procedure that returns data:
EXEC ('{CALL LIB.SP_TEST(?,?,?)}', 'Data', 'Data2', 'Data3') at AS400

i found a solution
select * from OPENQUERY(AS400,'SELECT * FROM LIB.TAB')

FWIW, I was getting this same error message along with a SQL7008 error code returned from the AS/400 whenever my code attempted to execute an UPDATE statement. While investigating, I found this article, http://www-01.ibm.com/support/docview.wss?uid=swg21007161, which led me to discover that journaling had been turned off earlier for the table in question due to scheduled upgrade to our ERP system and was never turned back on afterwards. Once journaling was turned back on, my updates began working again.

Related

OLE DB provider for linked server reported a change in schema version Error

I have a nightly job which is updates table by executing stored procedure but it keeps failing every 2-3 days.
DECLARE #return_value int
EXEC #return_value = [dbo].[sp_SRA_Analysis_Union]
SELECT 'Return Value' = #return_value
Below is the error message:
Step Name update table
Duration 00:00:30
Sql Severity 16
Sql Message ID 7359
Operator Emailed
Operator Net sent
Operator Paged
Retries Attempted 0
Message
Executed as user: NT AUTHORITY\SYSTEM.
The OLE DB provider "SQLNCLI10" for linked server "SQL05"
reported a change in schema version between
compile time ("182390105529348") and
run time ("182402990418943") for table "dbo"."CL_Midpoint"".
[SQLSTATE 42000] (Error 7359). The step failed.
Any idea/suggestions how to avoid this?
Thanks,
AR
Got the exact same error today. Did some research and found this: https://support.microsoft.com/en-us/kb/2498818
It appears to be a bug while using a linked server and synonym/aliases and/or views that refer to the linked server. In our case we had a linked server from SQL Server 2014 to SQL Server 2008R2. A reindex operation was run on a table that was being accessed using linked server (and the query was using a table alias for the linked server asset), we got this error.
Two things worked for me:
1. Just re-ran the SP and it worked fine.
2. Removed the table alias in the SP query and that resolved the issue for future too.
Got it fixed with following sql query inside problem db:
DBCC FREEPROCCACHE WITH NO_INFOMSGS;
where you delete the cache for the query that is causing the issue.

Transaction (Process ID) was deadlocked: Sql Server Management Studio

I'm trying to delete a database (from Sql Server Management Studio) and I receive this error:
Transaction (Process ID 52) was deadlocked on lock resources with
another process and has been chosen as the deadlock victim. Rerun the
transaction. (.Net SqlClient Data Provider)
I googled a lot (with a lot of result also here in so) but I cannot find any solution.
I really need to delete (and restore this db), but I'm stucked.
Any suggestion?
I guess you have open transactions. For example, for the database StackOverflow I am opening a transaction like this:
USE StackOverflow
BEGIN TRAN
and
USE StackOverflow
exec sp_whoisactive
So, when I try to deleted it:
I get the following error:
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot drop database "StackOverflow" because it is currently in use.
(Microsoft SQL Server, Error: 3702)
If I choose close existing connections from the delete interface the database is successfully deleted.

The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "DB_PROD_04" was unable to begin a distributed transaction

I have two servers:
SQL_UAT_01
DB_PROD_04
Both of these servers have the same database name and same tables:
SQL_UAT_01.Database_01.TestTable
DB_PROD_04.Database_01.TestTable
There is a trigger on each of these two tables.
When the trigger fires, it does a simple UPDATE on the table of the OTHER server.
Example
Trigger is fired here:
SQL_UAT_01.Database_01.Test
It does an update here:
DB_PROD_04.Database_01.Test
And vice-versa.
I'm running into an error which I have no clue how to fix.
Again, the error is this:
CallableStatementCallback; bad SQL grammar [{call
spGetAndIncrementIndex(?)}]; nested exception is
com.microsoft.sqlserver.jdbc.SQLServerException: The operation could
not be performed because OLE DB provider "SQLNCLI10" for linked server
"DB_PROD_04" was unable to begin a distributed transaction.
I have already linked the servers on both sides.
Does anyone have ANY idea how I should go about fixing this?
The answer was to install the DT on the server. It's a windows feature. I installed it and wahllah!
If a server runs out of local ports, you also get MSDTC issues
This is also fixed by correcting ephemeral TCP port saturation:
http://msdn.microsoft.com/en-us/library/aa560610%28v=bts.20%29.aspx

Insert into table.. exec at linked server does not work

This works, returning a resultset :
exec ('select ''col'', count(1) from test.dbo.[Table1] with (nolock)') at svrA
When I try to insert the resultset into a table:
insert into rowcount_sub (tablename,rowcnt)
exec ('select ''col'', count(1) from test.dbo.[Table1] with (nolock)') at svrA
Fails giving this error:
OLE DB provider "SQLNCLI10" for linked server "svrA" returned message "No transaction is active.".
Msg 7391, Level 16, State 2, Line 1
The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "svrA" was unable to begin a distributed transaction.
If you do not use distributed transaction on purpose, You can use advanced properties of the linked server object on main server to disable promotion of distributed transaction.
I was able to solve the same problem by using OPENQUERY instead of EXEC:
insert into rowcount_sub (tablename,rowcnt)
SELECT * FROM OPENQUERY(svrA, 'select ''col'', count(1) from test.dbo.[Table1] with (nolock)')
Hope it helps someone...
The operation could not be performed
because OLE DB provider "SQLNCLI10"
for linked server "svrA" was unable to
begin a distributed transaction.
The message is pretty clear and quite explicit. All you have to do is open your system documentation and follow the steps on configuring distributed transactions: Configuring MS DTC Services.
There are also plenty of blogs and tutorials out there:
How to configure DTC on Windows 2003
How to configure DTC on Windows 2008
Changing "Enable Promotion of Distributed Transaction" from True to false fixed my issue.

SQL Server: Snapshot transaction problem with synonyms in Express Edition

We have 2 databases, say DB1 and DB2.
DB1 contains all the stored procedures which access also data in DB2.
DB1 uses synonyms to access the tables in DB2.
(Using synonyms is a requirement in our situation)
This works perfectly fine in all situations with SQL Server 2005 Developer Edition.
However in the Express Edition, we get an exception when we do the following:
1 Restart SQL Server
2 Execute the following code within DB1:
set transaction isolation level snapshot
begin transaction
declare #sQuery varchar(max)
set #sQuery = 'Select * from synToSomeTableInDB2'
exec (#sQuery)
commit transaction
This will result in the following error:
Snapshot isolation transaction failed in database '...' because the database was not recovered when the current transaction was started. Retry the transaction after the database has recovered.
The same select query passes fine when used without the EXEC or when run on the Developer Edition.
Restarting the server in step 1 is important as once a connection was made to DB2, the code runs also fine on SQL Server Express Edition.
Does anyone have an idea what this is? We need to be able to use EXEC for some dynamic queries.
We've already checked MSDN, searched Google, ...
Any help is greatly appreciated.
--- Edit: March 10 09
As discussed with Ed Harper below, I've filed a bug report for this.
See https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=422150
As found out via Microsoft Connect, the problem is that by default on SQL Server Express Edition the AUTO_CLOSE option is set on true.
Changing this option to false fixes the problem.
The error message suggests that the query fails because SQL server is still recovering the database following the service restart when you execute your query.
Does the error always occur on the first attempt to run this code, regardless of the time elapsed since the service was restarted?
Can you confirm from the SQL Server log that the database is recovering correctly after the restart?