T_TEMPLATE_QUEUE and T_TEMPLATE_QUEUE_PARAMETER are likely to appear in the next version of the Table Structures document, but until they do, here are some tips:
Known Values of T_TEMPLATE_QUEUE.status:
Practical takeaway: if you want to use T_TEMPLATE_QUEUE as state, by querying it to exclude orders that have already received a certain template, make sure your exclusion filters on status <> -1 instead of status = 1.
status <> -1
status = 1
If you are queuing emails by inserting directly to these tables, AND YOU NEED TEMPLATE PARAMETERS, you have a couple of coding considerations:
The correct coding conventions to accommodate these requirements are to insert to both tables in an explicit transaction, and to use an INSERT-OUTPUT clause to get the generated identity IDs. Here is an example:
BEGIN TRANSACTION;CREATE TABLE #inserted ( id int, reference_no int,);INSERT dbo.T_TEMPLATE_QUEUE (template_no, email_profile_no, request_userid, request_usergroup, email_address, reference_no) OUTPUT INSERTED.id, INSERTED.reference_no INTO #insertedSELECT template_no, email_profile_no, request_userid, request_usergroup, email_address, reference_no FROM #inserting;WITH inserted_keyed AS ( SELECT template_queue_id = id, reference_no, order_sli_key = ROW_NUMBER() OVER (PARTITION BY reference_no ORDER BY id) FROM #inserted), inserting AS ( SELECT k.template_queue_id, [name] = 'sli_no', [value] = CONVERT(varchar, i.sli_no) FROM inserted_keyed k JOIN #inserting i ON k.reference_no = i.reference_no AND k.order_sli_key = i.order_sli_key)INSERT dbo.T_TEMPLATE_QUEUE_PARAMETERS (template_queue_id, [name], [value])SELECT template_queue_id, [name], [value] FROM inserting;COMMIT TRANSACTION;