SQL Server里查询表结构命令

环境:SQL Server 2008 R2

问题:查询表结构命令

       对MySQL和Oracle数据库熟悉的朋友知道用desc就可以查询一张表的结构,但是在SQL Server里执行desc命令会报错。

 desc Student; --关键字 'desc' 附近有语法错误。

       现提供两条命令查询表结构:

       1.sp_help table_name;

          如: sp_help Student;
       执行效果如下:
     SQL Server里查询表结构命令

      2.sp_columnstable_name;

           如: sp_columns Student;
           执行效果如下:

        SQL Server里查询表结构命令

推荐使用sp_help table_name,因为这条命令查询出的表结构信息更加详细。