It's not stupid, it's advanced
Filed under: ms+sql+server suckageI'm having to do some integration with an app based on MS SQL Server. It's a bit odd, but I just ran into my first real "WTF". I'm going to put this in its own paragraph so it stands out:
MS SQL Server has no LIMIT clause.
Yeah, so much for selecting a small sample at the CLI. Here's the suggested workaround:
SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (ORDER BY name) AS row FROM sys.databases ) a WHERE row > 5 and row <= 10
This is touted as "[t]he good news is that SQL Server 2005 makes this really easy". I guess they accidentally typed "easy" when what they really meant was "stupidly complicated".
[EDIT] No booleans either. Use char(1) and put 't' or 'f' in it they say. It's good to see Microsoft sucks on the backend as well as they do the desktop.







You are lucky you've got ROWNUMBER at all. I had to implement server-side paging with MSSQL 2000. Three nested SELECT TOP $number were needed...