I have the following query but I can't figure out the correct syntax to output the query result as a variable?
The query returns a record count on the Projects.dbo.Reports table on the linked server.
Any help would be greatly appreciated. Thanks Peter
EXEC ('Use Projects;
SELECT
SUM(p.row_count)
FROM sys.dm_db_partition_stats p
JOIN sys.objects o ON o.object_id = p.object_id
JOIN sys.schemas s ON o.schema_id = s.schema_id
WHERE p.index_id <2 AND o.type = ''U''
AND s.name = ''dbo''
AND o.name = ''Reports''
'
)AT [RemoteServer]