Tag: 重复预览模式: 普通 | 列表
SQL代码

  1.   
  2. --查询一个表中有效去掉重复的记录,UserID为自增长主键,RoleID为重复字段  
  3. Select MIN(UserID) AS UserID, RoleID FROM tmpTable GROUP BY RoleID  
  4. Select RoleID FROM tmpTable GROUP BY RoleID HAVING (COUNT(*) > 1)  
  5. Select DISTINCT * FROM tmpTable  
  6. sql语句查询 sql server access 数据库里的所有表名,字段名2007年02月01日 星期四 下午 04:21SQL SERVER  
  7. 查看所有表名:  
  8. select name from sysobjects where type='U'  
  9. 查询表的所有字段名:  
  10. Select name from syscolumns Where ID=OBJECT_ID('表名')  
  11. select * from information_schema.tables  
  12. select * from information_schema.views  
  13. select * from information_schema.columns  
  14. ACCESS  
  15. 查看所有表名:  
  16. select name from MSysObjects where type=1 and flags=0  
  17. MSysObjects是系统对象,默认情况是隐藏的。通过工具、选项、视图、显示、系统对象可以使之显示出来   
  18.    

Tags: SQL 重复

分类:MSSQL | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 46