Q: insert data into queue in sql server service broker I am trying to insert data into queue. The stored procedure fire_event will be used for this purpose. When ever this stored procedure is called, it should insert that data into the queue.. Below is the query and variables that will be passed from the stored procedure. Can some one tell me how to use this stored procedure to insert data in a queue in SQL Server. I want to replace the action of inserting into a table event_type by inserting it directly into a queue. Thanks
BEGIN

INSERT event_type
VALUES (@p_message_id,@p_event_type,@p_classifier,
        @p_event_time,@p_correlation_id,@p_person_id,@p_channel_id,
        @p_source_address_id,@p_agent_user,
        @p_agent_channel_id,@p_device_os,@p_device_os_version,
        @p_device_manufacturer,@p_device_model,@p_product_id,
        @p_event_source,@p_event_version,
        @p_node_id,@p_user_agent_string,@p_event_data)

END 


A: If you really mean Service Broker, then you should use SEND command.
For example, Service Broker objects:
Create Queue MyTableQueue;
Create Service MyTableService On Queue MyTableQueue([DEFAULT])
Create Queue  ProcessQueue;
Create Service ProcessService On Queue ProcessQueue([DEFAULT])

To send message:
Declare @h UniqueIdentifier;
Declare @doc xml;

Set @doc =
(
    Select 'Hello' Msg
    For XML Raw, Elements, Type, Root('Data')
);
Begin Dialog Conversation @h
From Service MyTableService
    To Service 'ProcessService'
With Encryption = OFF;

Send On Conversation @h(@doc)

or in your case (+ column aliases):
Declare @h UniqueIdentifier;
Declare @doc xml;

Set @doc =
(
    Select @p_message_id,@p_event_type,@p_classifier,@p_event_time,@p_correlation_id,@p_person_id,@p_channel_id,@p_source_address_id,@p_agent_user,
           @p_agent_channel_id,@p_device_os,@p_device_os_version,@p_device_manufacturer,@p_device_model,@p_product_id,@p_event_source,@p_event_version,
           @p_node_id,@p_user_agent_string,@p_event_data
    For XML Raw, Elements, Type, Root('Data')
);

Begin Dialog Conversation @h
From Service MyTableService
    To Service 'ProcessService'
With Encryption = OFF;

Send On Conversation @h(@doc)


A: CREATE PROCEDURE [dwhuser].[put_event] 
   @p_message_id            nvarchar(256),
   @p_event_type            nvarchar(256),
   @p_classifier             nvarchar(256),
   @p_event_time             datetime,
   @p_correlation_id         nvarchar(256),
   @p_person_id              nvarchar(256),
   @p_channel_id             nvarchar(256),
   @p_source_address_id      nvarchar(256),
   @p_agent_user             nvarchar(256),
   @p_agent_channel_id       nvarchar(256),
   @p_device_os              nvarchar(256),
   @p_device_os_version      nvarchar(256),
   @p_device_manufacturer    nvarchar(256),
   @p_device_model           nvarchar(256),
   @p_product_id             nvarchar(256),
   @p_event_source           nvarchar(256),
   @p_event_version          nvarchar(256),
   @p_node_id                nvarchar(256),
   @p_user_agent_string      nvarchar(2000),
   @p_event_data             VARBINARY(MAX)

AS
  BEGIN
BEGIN TRY
   INSERT [aq_event_type]
   VALUES (@p_message_id,@p_event_type,@p_classifier,@p_event_time,@p_correlation_id,@p_person_id,@p_channel_id,@p_source_address_id,@p_agent_user,
           @p_agent_channel_id,@p_device_os,@p_device_os_version,@p_device_manufacturer,@p_device_model,@p_product_id,@p_event_source,@p_event_version,
           @p_node_id,@p_user_agent_string,@p_event_data)


END TRY
BEGIN CATCH    

