question

peter_marshall_construction_com avatar image
peter_marshall_construction_com asked

Syntax question for an 'EXEC () AT' query

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]

sql querysyntax
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.