SQL使用语句大全.docVIP

  • 0
  • 0
  • 约8.32千字
  • 约 8页
  • 2016-12-29 发布于重庆
  • 举报
SQL 技巧 1、1=1,1=2的使用,在SQL语句组合时用的较多 “where 1=1” 是表示选择全部??? “where 1=2”全部不选, 如: if @strWhere != begin set @strSQL = select count(*) as Total from [ + @tblName + ] where + @strWhere end else begin set @strSQL = select count(*) as Total from [ + @tblName + ] end 我们可以直接写成 错误!未找到目录项。 set @strSQL = select count(*) as Total from [ + @tblName + ] where 1=1 安定 + @strWhere 2、收缩数据库 --重建索引 DBCC REINDEX DBCC INDEXDEFRAG --收缩数据和日志 DBCC SHRINKDB DBCC SHRINKFILE 3、压缩数据库 dbcc shrinkdatabase(dbname) 4、转移数据库给新用户以已存在用户权限 exec sp_change_users_login update_one,newname,oldname go 5、检查备份集 RESTORE VERIFYONLY fr

文档评论(0)

1亿VIP精品文档

相关文档