Notificações de consulta-sys.dm_qn_subscriptionsQuery Notifications - sys.dm_qn_subscriptions
Aplica-se a:Applies to: SQL ServerSQL Server (todas as versões compatíveis)
SQL ServerSQL Server (all supported versions)
SQL ServerSQL Server (todas as versões compatíveis)
SQL ServerSQL Server (all supported versions)
Retorna informações sobre as assinaturas de notificações de consulta ativa no servidor.Returns information about the active query notifications subscriptions in the server. Você pode usar essa exibição para verificar assinaturas ativas no servidor ou em um banco de dados especificado, ou verificar um principal de servidor especificado.You can use this view to check for active subscriptions in the server or a specified database, or to check for a specified server principal.
Nome da colunaColumn name | Tipo de dadosData type | DescriçãoDescription |
---|---|---|
idid | intint | ID de uma assinatura.ID of a subscription. |
database_iddatabase_id | intint | ID do banco de dados no qual a consulta de notificação foi executada.ID of the database in which the notification query was executed. Esse banco de dados armazena informações relativas a essa assinatura.This database stores information related to this subscription. |
SIDssid | varbinary(85)varbinary(85) | ID de segurança do principal do servidor que criou e detém essa assinatura.Security ID of the server principal that created and owns this subscription. |
object_idobject_id | intint | ID da tabela interna que armazena informações sobre parâmetros de assinatura.ID of the internal table that stores information about subscription parameters. |
createdcreated | datetimedatetime | Data e hora em que a assinatura foi criada.Date and time that the subscription was created. |
timeouttimeout | intint | Tempo limite para a assinatura em segundos.Time-out for the subscription in seconds. A notificação será sinalizada para disparar após o decorrer desse período.The notification will be flagged to fire after this time has elapsed. Observação: a hora de acionamento real pode ser maior que o tempo limite especificado. No entanto, se uma alteração que invalida a assinatura ocorrer após o tempo limite especificado, mas antes de a assinatura ser acionada, o SQL ServerSQL Server acionamento ocorrerá no momento em que a alteração foi feita.Note: The actual firing time may be greater than the specified time-out. However, if a change that invalidates the subscription occurs after the specified time-out, but before the subscription is fired, SQL ServerSQL Server ensures that firing occurs at the time that the change was made. |
statusstatus | intint | Indica o status da assinatura.Indicates the status of the subscription. Veja a tabela abaixo dos comentários para obter a lista de códigos.See the table under remarks for the list of codes. |
Cardinalidades de relaçõesRelationship Cardinalities
DeFrom | ParaTo | AtivadoOn | TypeType |
---|---|---|---|
sys.dm_qn_subscriptionssys.dm_qn_subscriptions | sys.databasessys.databases | database_iddatabase_id | Muitos para umMany-to-one |
sys.dm_qn_subscriptionssys.dm_qn_subscriptions | sys.internal_tablessys.internal_tables | object_idobject_id | Muitos para umMany-to-one |
ComentáriosRemarks
O código de status 0 indica um status indefinido.The status code of 0 indicates an undefined status.
Os códigos de status a seguir indicam que uma assinatura foi acionada devido a uma alteração:The following status codes indicate that a subscription fired because of a change:
CódigoCode | Status secundárioMinor status | InfoInfo |
---|---|---|
6579865798 | Assinatura acionada porque os dados foram alteradosSubscription fired because data changed | Assinatura disparada por inserçãoSubscription triggered by insert |
6579965799 | Assinatura acionada porque os dados foram alteradosSubscription fired because data changed | ExcluirDelete |
6580065800 | Assinatura acionada porque os dados foram alteradosSubscription fired because data changed | AtualizarUpdate |
6580165801 | Assinatura acionada porque os dados foram alteradosSubscription fired because data changed | MesclarMerge |
6580265802 | Assinatura acionada porque os dados foram alteradosSubscription fired because data changed | Truncar tabelaTruncate table |
6604866048 | Assinatura acionada porque o tempo limite expirouSubscription fired because timeout expired | Modo de informações indefinidoUndefined info mode |
6631566315 | Assinatura acionada porque os objetos foram alteradosSubscription fired because object changed | objeto ou usuário removidoobject or user was dropped |
6631666316 | Assinatura acionada porque os objetos foram alteradosSubscription fired because object changed | objeto alteradoobject was altered |
6656566565 | Assinatura acionada porque o banco de dados foi desanexado ou removidoSubscription fired because database was detached or dropped | servidor ou db reiniciadoserver or db restarted |
6657166571 | Assinatura acionada porque o banco de dados foi desanexado ou removidoSubscription fired because database was detached or dropped | objeto ou usuário removidoobject or user was dropped |
6657266572 | Assinatura acionada porque o banco de dados foi desanexado ou removidoSubscription fired because database was detached or dropped | objeto alteradoobject was altered |
6734167341 | assinatura disparada devido à falta de recursos no servidorsubscription was triggered because of lack od resources on the server | assinatura disparada devido à falta de recursos no servidorsubscription was triggered because of lack od resources on the server |
Os códigos de status a seguir indicam que uma assinatura não pôde ser criada:The following status codes indicate that a subscription failed to be created:
CódigoCode | Status secundárioMinor status | InfoInfo |
---|---|---|
132609132609 | A criação de assinatura falhou porque não há suporte à instruçãoSubscription creation failed because the statement is not supported | Consulta muito complexaQuery is too complex |
132610132610 | A criação de assinatura falhou porque não há suporte à instruçãoSubscription creation failed because the statement is not supported | Instrução inválida para assinaturaInvalid statement for subscription |
132611132611 | A criação de assinatura falhou porque não há suporte à instruçãoSubscription creation failed because the statement is not supported | Opções definidas inválidas para assinaturaInvalid set options for subscription |
132612132612 | A criação de assinatura falhou porque não há suporte à instruçãoSubscription creation failed because the statement is not supported | Nível de isolamento inválidoInvalid isolation level |
132622132622 | A criação de assinatura falhou porque não há suporte à instruçãoSubscription creation failed because the statement is not supported | usado internamenteused internally |
132623132623 | A criação de assinatura falhou porque não há suporte à instruçãoSubscription creation failed because the statement is not supported | acima do limite do modelo por tabelaover the template limit per table |
Os códigos de status a seguir são usados internamente e são classificados como modos de check kill e init:The following status codes are used internally and are classed as check kill and init modes:
CódigoCode | Status secundárioMinor status | InfoInfo |
---|---|---|
198656198656 | Usado internamente: modos check kill e initUsed internally: check kill and init modes | Modo de informações indefinidoUndefined info mode |
198928198928 | Assinatura destruídaSubscription was destroyed | Assinatura acionada porque o banco de dados foi anexadoSubscription fired because db was attached |
198929198929 | Assinatura destruídaSubscription was destroyed | Assinatura acionada porque o usuário foi removidoSubscription fired because user was dropped |
198930198930 | Assinatura destruídaSubscription was destroyed | Assinatura removida devido a uma nova assinaturaSubscription was dropped because of a resubscription |
198931198931 | Assinatura destruídaSubscription was destroyed | assinatura eliminadasubscription was killed |
199168199168 | Assinatura ativaSubscription is active | Modo de informações indefinidoUndefined info mode |
199424199424 | Assinatura inicializada, mas não ativa aindaSubscription initialized but not yet active | Modo de informações indefinidoUndefined info mode |
PermissõesPermissions
Requer a permissão VIEW SERVER STATE no servidor.Requires VIEW SERVER STATE permission on server.
Observação
Se o usuário não tiver a permissão VIEW SERVER STATE, essa exibição retornará informações sobre as assinaturas de propriedade do usuário atual.If the user does not have VIEW SERVER STATE permission, this view returns information about subscriptions owned by current user.
ExemplosExamples
a.A. Retornar assinaturas ativas de notificação de consulta para o usuário atualReturn active query notification subscriptions for the current user
O exemplo a seguir retorna assinaturas ativas de notificação de consulta para o usuário atual.The following example returns the active query notification subscriptions of the current user. Se o usuário tiver permissões VIEW SERVER STATE, todas as assinaturas ativas no servidor serão retornadas.If the user has VIEW SERVER STATE permissions, all active subscriptions in the server are returned.
SELECT id, database_id, sid, object_id, created, timeout, status
FROM sys.dm_qn_subscriptions;
GO
B.B. Retornar assinaturas ativas de notificação de consulta para um usuário especificadoReturning active query notification subscriptions for a specified user
O exemplo a seguir retorna assinaturas ativas de notificação de consulta feitas pelo logon Ruth0
.The following example returns the active query notification subscriptions subscribed by login Ruth0
.
SELECT id, database_id, sid, object_id, created, timeout, status
FROM sys.dm_qn_subscriptions
WHERE sid = SUSER_SID('Ruth0');
GO
C.C. Retornando metadados de tabela interna para assinaturas de notificação de consultaReturning internal table metadata for query notification subscriptions
O exemplo a seguir retorna os metadados de tabela interna para assinaturas de notificação de consulta.The following example returns the internal table metadata for query notification subscriptions.
SELECT qn.id AS query_subscription_id
,it.name AS internal_table_name
,it.object_id AS internal_table_id
FROM sys.internal_tables AS it
JOIN sys.dm_qn_subscriptions AS qn ON it.object_id = qn.object_id
WHERE it.internal_type_desc = 'QUERY_NOTIFICATION';
GO
Consulte TambémSee Also
Exibições e funções de gerenciamento dinâmico (Transact-SQL) Dynamic Management Views and Functions (Transact-SQL)
Exibições de gerenciamento dinâmico relacionadas a notificações de consulta ()Transact-SQL Query Notifications Related Dynamic Management Views (Transact-SQL)
KILL QUERY NOTIFICATION SUBSCRIPTION (Transact-SQL)KILL QUERY NOTIFICATION SUBSCRIPTION (Transact-SQL)