示例1-7.sql
资源名称:1.rar [点击查看]
上传用户:szjinfuhao
上传日期:2015-10-11
资源大小:1260k
文件大小:1k
源码类别:

SQL Server

开发平台:

SQL

  1. SE S_C_SC
  2. GO
  3. SET NOCOUNT ON
  4. DECLARE @ConversationHandle uniqueidentifier;
  5. DECLARE @MsgBody nvarchar(MAX);
  6. DECLARE @MsgTypeName sysname;
  7. BEGIN TRAN
  8. WAITFOR 
  9. (
  10.     RECEIVE TOP (1)
  11. @MsgTypeName = message_type_name,  
  12. @ConversationHandle = conversation_handle,    
  13. @MsgBody = message_body
  14.         FROM [TargetQueue]
  15. ), TIMEOUT 60;
  16. PRINT @MsgBody 
  17. -- if the message is from the initiator, then respond
  18. IF @MsgTypeName = N'SourceMessage'
  19. BEGIN 
  20.         -- Send the response to the request initiator
  21.        SEND ON CONVERSATION @ConversationHandle
  22.    MESSAGE TYPE [TargetMessage] (N'Hi! this Response from database S_C_SC');
  23.         -- no more messages/end of conversation
  24.         END CONVERSATION @ConversationHandle;
  25. END
  26. COMMIT
  27. GO