I have been troubleshooting a replication problem, according to the picture below:
with reference to the picture above,
the bit that says Sessions of the distribution agent I can get using the following query:
--================================================================================
-- finally the contents
-- sessions of the distribution agent:
--================================================================================
use [master]
exec [distribution]..sp_MSenum_distribution_s
@name = N'MYSERVER-Product-Product-MYSUBSCRIPTION-184',
@hours = -1,
@session_type = 1
Actions in the selected session
--========================================================
-- get the actions in the selected session:
-- for each row on the above data, we can get the details:
--========================================================
-- example of the last session - without errors
use [master]
exec [distribution]..sp_MSenum_distribution_sd
@name = N'MYSERVER-Product-Product-MYSUBSCRIPTION-184',
@time = N'20170411 14:16:03.920'
-- example of the second session - with errors
use [master]
exec [distribution]..sp_MSenum_distribution_sd
@name = N'MYSERVER-Product-Product-MYSUBSCRIPTION-184',
@time = N'20170410 15:50:27.650'
Now this bit of code below gives me the errors I am looking for:
Error details or message of the solected session:
And here goes the Question too:
How can I get the number 5468694 from the result above and use it in the query below?
--========================================================================
-- Error details or message of the solected session:
--=========================================================================
use [master]
exec [distribution]..sp_MSenum_distribution_sd
@name = N'SQLAPPLON1-Product-Product-REPLON1-184',
@time = N'20170410 15:50:27.650'
use [master]
exec [distribution]..sp_MSget_repl_error
@id = 5468694