flwyd: (farts sign - Norway)
The following is legal syntax in SQL Server 2005:
select * from my_table t where t.foo = 1

The following is not legal syntax in SQL Server 2005:
delete from my_table t where t.foo = 1

In this example, the table alias doesn't add anything, but it does in the following:
delete from my_table t1 where foo = 1 and not exists (select null from my_table t2 where t2.foo = 2 and t1.id = t2.id)

Table aliases are necessary to do same-table subselects and joins, and SQL Server will happily let you use them to find out what data you plan to delete, but not to actually delete that same data. I instead switched to
delete from my_table t1 where foo = 1 and id not in (select id from my_table t2 where t2.foo = 2)
which takes a really long time because it does the subselect for every row matching foo = 1.

If Microsoft's implementation of SQL were compared to Microsoft's implementations of JavaScript/DOM/CSS, I suspect the latter would have way more annoying quirks, but the former has way more annoying basic problems. The fact that my CD started skipping while sorting this out (and probably need to be returned to the store) adds to the general grumpiness of the moment.
flwyd: (mathnet - to cogitate and to solve)
When your DBA moves a database, it's a good idea to make sure all the tables still have their primary keys. I discovered this week that Oracle and SQL Server both enable you to move tables while leaving indexes behind.

It may be a sign of a strong framework when your software operates more or less successfully even when 75% of your tables lack proper unique constraints.

It may be a sign of good luck when this sort of thing only happens to (a) training databases and (b) production databases deployed in a situation in which data loss is not a big deal.
December 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 2025

Most Popular Tags

Expand Cut Tags

No cut tags

Subscribe

RSS Atom
Page generated Monday, December 29th, 2025 05:57 am
Powered by Dreamwidth Studios