Another samples

//select all entities within the bulk - the bulk_top (BIT) column is added to identify the top entity in a bulk
SELECT CAST(CASE WHEN EXISTS(SELECT * FROM EcASSOC WHERE EcENTITY.id=EcASSOC.ent_id_child) THEN 0 
ELSE 1 END AS BIT) AS bulk_top, * FROM EcENTITY WHERE bulk_id=@BulkId ORDER BY id DESC

//all association records EcASSOC joined with the child entity attributes (all bulk associations)
SELECT EcENTITY.*, EcASSOC.* FROM EcASSOC LEFT JOIN EcENTITY ON EcASSOC.ent_id_child=EcENTITY.id 
WHERE (EcENTITY.bulk_id=@BulkId)

Warning

never update (change) the EcENTITY.comm_dir value in the bulk! The whole bulk must have a single EcENTITY.comm_dir value!

Last updated