For a rigorous marker of the source database state, I'd like to capture the @@DBTS of an external database in a sproc. Yeah, I think I could issue
USE ExternalDB
GO
SELECT @myVarbinary8 = @@DBTS
GO
USE OriginalDB
GO
but, even if I could, it seems ugly.
For now, I've embedded a scalar-valued function in the source database to invoke the
SET @Result = SELECT @@DBTS
which worked fine until I forgot to ask the DBA to grant the appropriate rights for a new user, which crashed a process.
Something akin to
SELECT ExternalServer.dbo.@@DBTS
(I know that doesn't work).
See MSDN @@DBTS documentation
@@DBTS (Transact-SQL)
Returns the value of the current timestamp data type for the current database.
This timestamp is guaranteed to be unique in the database.