By default, PostgreSQL (PSQL to its friends) formats time intervals in a way that makes it much more human-readable, which is nice until you have intervals longer than a day and you want to manipulate the data further in something like Microsoft Excel. To make the time intervals machine-readable again,…
By putting SQL Server into single-user mode, you can log in using any Windows administrator account with sysadmin permissions, even if an equivalent SQL login does not exist. This is very useful when you’ve lost sysadmin access (not-entirely-hypothetical example: someone set up a database, removed all sysadmin accounts except sa,…
Easy as: sp_msforeachtable ‘ALTER TABLE ? NOCHECK CONSTRAINT all’ GO sp_msforeachtable ‘DELETE ?’ GO sp_msforeachtable ‘ALTER TABLE ? CHECK CONSTRAINT all’ GO
I was using RAND() in an INSERT statement, using values SELECTed from a different table. I assumed that RAND() would be executed for each row from the SELECT statement, but instead I discovered it is only executed once per query. Simple gotcha. INSERT TableName (ColumnA, ColumnB, ColumnC) — RAND() is…