高级SQL语句使用

1、列出数据库中所有表明

  select name from sysobjects where type='U' // U代表用户

2、列出表中所有列名

    select name from syscolumns where id=object_id('TableName')

3、更改某个表名:

   exec sp_changeobjectowner 'tablename','dbo'

4、按姓氏笔画排序

   Select * From TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as  --从少到多

5、获取某个表的所有字段

  select name from syscolumns where id=object_id('表名')

6、查询表中字段的类型

  select column_name,data_type from information_schema.columns where table_name = '表名'

原文地址:https://www.cnblogs.com/wangpf/p/3029951.html