我有一個表「N」列 &我必須寫一個簡單的查詢是這樣的:需要優化SQL Server查詢
SELECT col_1,col_2,col_3,...col_n FROM SingleTableOnly
WHERE col_1 IS NOT NULL
AND col_2 IS NOT NULL
AND col_3 IS NOT NULL
... -- for each column i need to put this condition again & again
AND col_n IS NOT NULL
請建議我爲同一更好的邏輯。
還能有這樣的:
SELECT ALL COLUMNS FROM SingleTableOnly
WHERE ALL COLUMNS IS NOT NULL
-- i know this isnt right sql query, but trying to figure something where i can write less.
這是特定於MS SQL Server 2005的唯一。
沒有其他你正在描述的where子句的方式。 – 2011-01-12 07:01:20
您可以通過編寫視圖並從中進行選擇來繞過這個問題。 – 2011-01-12 07:32:15