I don't remember seeing it for other queries, but it consistently happens for this one view definiton;
SELECT important_messages.id, name, alias, operation AS product_operation, important_messages.message, comment_startup, comment_stop, registered, registered_by, selection.article, batch, counter, from_date, to_date FROM ( SELECT dbo.important_messages.id, dbo.important_message_limit_batches.article, batch FROM dbo.important_messages JOIN dbo.important_message_operations ON (dbo.important_messages.id = dbo.important_message_operations.message) JOIN hqas_product_operations ON (dbo.important_message_operations.operation = dbo.hqas_product_operations.id) JOIN dbo.important_message_limit_batches ON dbo.important_messages.id = dbo.important_message_limit_batches.message UNION SELECT dbo.important_messages.id, dbo.hqas_batch_operations.article, dbo.hqas_batch_operations.batch FROM dbo.important_messages JOIN dbo.important_message_operations ON (dbo.important_messages.id = dbo.important_message_operations.message) JOIN hqas_product_operations ON (dbo.important_message_operations.operation = dbo.hqas_product_operations.id) JOIN dbo.hqas_batch_operations ON dbo.hqas_product_operations.id = dbo.hqas_batch_operations.source JOIN dbo.hqas_batches ON dbo.hqas_batch_operations.article = dbo.hqas_batches.article AND dbo.hqas_batch_operations.batch = dbo.hqas_batches.batch JOIN dbo.important_message_limit_count ON dbo.important_messages.id = dbo.important_message_limit_count.message WHERE counter > 0 UNION SELECT dbo.important_messages.id, dbo.hqas_batch_operations.article, batch FROM dbo.important_messages JOIN dbo.important_message_operations ON (dbo.important_messages.id = dbo.important_message_operations.message) JOIN hqas_product_operations ON (dbo.important_message_operations.operation = dbo.hqas_product_operations.id) JOIN dbo.hqas_batch_operations ON dbo.hqas_product_operations.id = dbo.hqas_batch_operations.source JOIN dbo.important_message_limit_date ON dbo.important_messages.id = dbo.important_message_limit_date.message WHERE GETDATE() BETWEEN from_date AND to_date ) AS selection JOIN important_messages ON selection.id = dbo.important_messages.id JOIN dbo.important_message_operations ON (dbo.important_messages.id = dbo.important_message_operations.message) JOIN hqas_product_operations ON (dbo.important_message_operations.operation = dbo.hqas_product_operations.id) LEFT JOIN important_message_limit_count ON (important_messages.id = important_message_limit_count.message) LEFT JOIN important_message_limit_date ON (important_messages.id = important_message_limit_date.message)
and counter is only in the table important_message_limit_count, I do believe.
Maybe it gets confused by the left join outside the subquery part where this popup is opened..
Answers
SELECT
important_messages.id, name, alias, operation AS product_operation, important_messages.message, comment_startup, comment_stop,
registered, registered_by, selection.article, batch, counter, from_date, to_date
FROM (
SELECT
dbo.important_messages.id,
dbo.important_message_limit_batches.article,
batch
FROM dbo.important_messages
JOIN dbo.important_message_operations ON (dbo.important_messages.id = dbo.important_message_operations.message)
JOIN hqas_product_operations ON (dbo.important_message_operations.operation = dbo.hqas_product_operations.id)
JOIN dbo.important_message_limit_batches ON dbo.important_messages.id = dbo.important_message_limit_batches.message
UNION
SELECT
dbo.important_messages.id,
dbo.hqas_batch_operations.article,
dbo.hqas_batch_operations.batch
FROM dbo.important_messages
JOIN dbo.important_message_operations ON (dbo.important_messages.id = dbo.important_message_operations.message)
JOIN hqas_product_operations ON (dbo.important_message_operations.operation = dbo.hqas_product_operations.id)
JOIN dbo.hqas_batch_operations ON dbo.hqas_product_operations.id = dbo.hqas_batch_operations.source
JOIN dbo.hqas_batches ON dbo.hqas_batch_operations.article = dbo.hqas_batches.article AND dbo.hqas_batch_operations.batch = dbo.hqas_batches.batch
JOIN dbo.important_message_limit_count ON dbo.important_messages.id = dbo.important_message_limit_count.message
WHERE counter > 0
UNION
SELECT
dbo.important_messages.id,
dbo.hqas_batch_operations.article,
batch
FROM dbo.important_messages
JOIN dbo.important_message_operations ON (dbo.important_messages.id = dbo.important_message_operations.message)
JOIN hqas_product_operations ON (dbo.important_message_operations.operation = dbo.hqas_product_operations.id)
JOIN dbo.hqas_batch_operations ON dbo.hqas_product_operations.id = dbo.hqas_batch_operations.source
JOIN dbo.important_message_limit_date ON dbo.important_messages.id = dbo.important_message_limit_date.message
WHERE GETDATE() BETWEEN from_date AND to_date
) AS selection
JOIN important_messages ON selection.id = dbo.important_messages.id
JOIN dbo.important_message_operations ON (dbo.important_messages.id = dbo.important_message_operations.message)
JOIN hqas_product_operations ON (dbo.important_message_operations.operation = dbo.hqas_product_operations.id)
LEFT JOIN important_message_limit_count ON (important_messages.id = important_message_limit_count.message)
LEFT JOIN important_message_limit_date ON (important_messages.id = important_message_limit_date.message)