MS SQL “ON DELETE CASCADE” multiple foreign keys pointing to the same table?

You’ll have to implement this as an INSTEAD OF delete trigger on insights, to get it to work. Something like: create trigger T_Insights_D on Insights instead of delete as set nocount on delete from broader_insights_insights where insight_id in (select ID from deleted) or broader_insight_id in (select ID from deleted) delete from Insights where ID in … Read more

PostgreSQL ORDER BY issue – natural sort

Since Postgres 9.6, it is possible to specify a collation which will sort columns with numbers naturally. https://www.postgresql.org/docs/10/collation.html — First create a collation with numeric sorting CREATE COLLATION numeric (provider = icu, locale=”[email protected]=yes”); — Alter table to use the collation ALTER TABLE “employees” ALTER COLUMN “em_code” type TEXT COLLATE numeric; Now just query as you … Read more