new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Drizzle ORM · all subjects

mssql/delete

5 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Delete all rows from table in MSSQL

To delete all rows from a table in MSSQL, use `await db.delete(users)` with no where clause. This deletes every row in the specified table.

Delete with where condition in MSSQL

To delete rows with a condition in MSSQL, use `await db.delete(users).where(eq(users.name, 'Dan'))`. The where clause filters which rows to delete.

Delete and return deleted row in MSSQL

In MSSQL, you can delete a row and get it back using the `.output()` method. Call `.output()` with no arguments to return all columns of deleted rows. Example: `await db.delete(users).where(eq(users.name, 'Dan')).output()` returns the deleted user objects.

Delete and return partial columns in MSSQL

In MSSQL, you can delete a row and return only specific columns using `.output()` with a column selection object. Example: `await db.delete(users).where(eq(users.name, 'Dan')).output({ deletedId: users.id })` returns an array with shape `{ deletedId: number }[]`, containing only the selected columns from deleted rows.

MSSQL delete OUTPUT clause syntax

MSSQL uses the OUTPUT clause with the DELETED keyword to return deleted rows. Example SQL: `delete from [users] output DELETED.[id], DELETED.[name], DELETED.[age] where [users].[name] = 'Dan'`. The DELETED keyword references the values of deleted rows.

Give your agent this brain