All pastes #267931 Raw Edit

Mine

public sql v1 · immutable
·published 2006-12-05 05:28 UTC
rendered paste body
CREATE TRIGGER InsertProperty ON PropertyINSTEAD OF InsertAS BEGINdeclare @PropertyId bigintDECLARE c1 CURSOR FORSELECT PropertyIdFROM insertedFOR UPDATE OF PropertyId OPEN c1FETCH NEXT FROM c1INTO @PropertyIdWHILE @@FETCH_STATUS = 0BEGIN	--Insert into identity table		insert into Entity (EntityTypeId)	Values(1) --One is a property type		    --Update the records about to be inserted.	UPDATE inserted	SET PropertyId = @@Identity	WHERE CURRENT OF c1ENDinsert into Property select * from insertedEND