So how do I go about using an OPENROWSET command to set a variable based on a remote COUNT(*) of a table.
I know it does not look like this ... but here is what I am after:
What I am doing is loading @Pub, @PubDB and @Art with values that will give me a 3 part name (that being Server.DB.Table).
Ultimately trying to get the record count of the table I have strung together and then populate my variable @P with the count.
Thanks ALL!
Thanks
J. Kusch
I know it does not look like this ... but here is what I am after:
Code:
declare @P Int,
@Pub VarChar(20),
@Pub_DB VarChar(20),
@Art VarChar(20)
SELECT @P = COUNT(*)
FROM OPENROWSET('SQLOLEDB', 'Server=MySrvr;Trusted_Connection=yes;',
'SELECT COUNT(*) FROM ' + @Pub + '.' + @Pub_DB + '.' + @Art + '' )
What I am doing is loading @Pub, @PubDB and @Art with values that will give me a 3 part name (that being Server.DB.Table).
Ultimately trying to get the record count of the table I have strung together and then populate my variable @P with the count.
Thanks ALL!
Thanks
J. Kusch