1、重置 Identity 字段的起始值 DBCC CHECKIDENT ( '[table-name]', RESEED, 0 )
2、压缩数据库 (清除 transaction log) DUMP TRANSACTION [database-name] WITH NO_LOG
3、动态 top xxx Set ROWCOUNT = xxx 错的 set rowcount 0 select时显示所有记录 set rowcount 1 select时显示一条记录,但可以指定top xx显示多条记录
4、动态 order by 注意动态排序字段需要类型相同,如都是数值或字符,或者可以相互转换 select ...from ... where order by case when @ord=1 then name end, case when @ord=-1 then name end desc 或者 ORDER BY CASE @OrderBy WHEN 'CompanyName' THEN CompanyName WHEN 'ContactName' THEN ContactName END
5、创建、调用 COM 对象 (RegEx) http://sqlteam.com/item.asp?ItemID=13947
6、用 temp table 而不用 cursor select into #t while exist(select ... from #t where xxx) begin .... delete from #t where xxx end
2005-9-23 11:08:12
|