service borker奇怪的问题,最后50分
随便新建一个数据库,执行以下脚本,service borker都能正常运行。
但如果附加的数据库或者是还原的数据库,执行以下脚本,连队列消息都发送不了。会是什么原因?
------------------------------
CREATE TABLE CLICKLOG
(
id INT IDENTITY(1,1),
departure char(3),
destination char(3),
LeaveDate datetime,
returndate datetime,
flightid int,
clickdate datetime,
ipaddress varchar(50)
);
go
CREATE MESSAGE TYPE [RecordClick] VALIDATION = NONE;
CREATE CONTRACT [ClickContract]
(
[RecordClick] SENT BY INITIATOR
);
CREATE QUEUE [ClickQueue];
CREATE SERVICE [ClickService] ON QUEUE [ClickQueue]([ClickContract]);
GO
CREATE QUEUE [RecordClickQueue];
CREATE SERVICE [RecordClickService] ON QUEUE [RecordClickQueue];
go
---------------------
----------------------
CREATE PROCEDURE clicklogadditem
AS
BEGIN
DECLARE @Handle UNIQUEIDENTIFIER;
DECLARE @MessageType SYSNAME;
DECLARE @Message XML ;
DECLARE @Departure char(3);
DECLARE @Destination char(3);
DECLARE @LeaveDate datetime;
DECLARE @ReturnDate datetime;
DECLARE @Flightid int;
DECLARE @clickDate datetime ;
DECLARE @IpAddress varchar(50);
RECEIVE TOP (1)
@Handle = conversation_handle,
@MessageType = message_type_name,
@Message = message_body
FROM [ClickQueue];
IF(@Handle IS NOT NULL AND @Message IS NOT NULL)
BEGIN
SELECT @Departure = CAST(CAST(@Message.query( '/Params/Departure/text() ') AS NVARCHAR(MAX)) AS char(3))
SELECT @Destination = CAST(CAST(@Message.query( '/Params/Destination/text() ') AS NVARCHAR(MAX)) AS char(3))
SELECT @LeaveDate = CAST(CAST(@Message.query( '/Params/LeaveDate/text() ') AS NVARCHAR(MAX)) AS Datetime)
&nb