Sql-server – Affected rows after update with OpenQuery

linked-serversql serverupdate

Is there a way to get the affected row count, when updating through an connection server?

I'm using MSSQL connected to MySQL with ODBC.

UPDATE OPENQUERY (MyConnection, 'UPDATE recordid, status FROM table WHERE status=0') SET status=1

Best Answer

Use a modified Linked Server Naming Convention Instead with @@rowcount

UPDATE  [linkedServerName]...[databaseName.TableName] 
set status=1 WHERE status=0
select @@rowcount

Note:

Follow these steps to get Microsoft SQL Server linked server naming convention to work with MySQL:

https://stackoverflow.com/questions/31968343/select-from-mysql-linked-server-using-sql-server-without-openquery

you can use the statement below

select * from [linkedServerName]...[databaseName.TableName]

but before executing the code above ,, you have to do some changes ..

in the SQL Server Management Studio , go to "linked servers" Folder , open Providers Folder , find MSDASQL and gets it's propertythen check "Level Zero Only" press Ok ... then execute above query and Enjoy it !!!