也許是離開t-sql太久了,突然發現很多t-sql的奇特語法
用一句sql解決多種排序:
declare @flag int=0; SELECT C1, C2 FROM T ORDER BY CASE WHEN @flag = 1 THEN C1 END ASC, CASE WHEN @flag = 0 THEN C1 END DESC
插入N行資料(省得每行資料寫一遍insert ... values了):
insert into t (C1, C2) values (1,1), (2,2), ... (N-1,N-1), (N,N)