• 查询表字段信息


    string sql = string.Format(@"
                                SELECT
                                    syscolumns.colid,
                                    Sysobjects.name AS [TableName],
                                    syscolumns.name AS [ColumnName],
                                    systypes.name AS [DataType],
                                    syscolumns.length AS [DataLength],
                                    sys.extended_properties.[value] AS [Description],  
                                    syscomments.text AS [DefaultValue],
                                    syscolumns.isnullable AS [NullAble]    
                                FROM
                                    syscolumns INNER JOIN systypes
                                    ON syscolumns.xtype = systypes.xtype
                                    LEFT JOIN sysobjects ON syscolumns.id = sysobjects.id
                                    LEFT OUTER JOIN sys.extended_properties ON
                                    ( sys.extended_properties.minor_id = syscolumns.colid
                                    AND sys.extended_properties.major_id = syscolumns.id)
                                    LEFT OUTER JOIN syscomments ON syscolumns.cdefault = syscomments.id
                                WHERE syscolumns.id IN
                                (SELECT id FROM SYSOBJECTS WHERE xtype = 'U' AND NAME = '{0}') AND (systypes.name <> 'sysname')
                                ORDER BY syscolumns.colid
    ", tbName);
  • 相关阅读:
    (转)MyEclipse +Servlet
    Android: MediaRecorder start failed
    Android: 帮助找出内存泄漏的工具
    Node & Express: some tips
    MySQL: Create Master
    scp: useful commands
    MySQL: 打开binlog选项后无法重启MySQL
    IIS: 配置web.config解决Maximum request length exceeded错误
    MySQL: 让MySQL支持颜文字emoji
    Linux: 通过命令行上传文件到ftp服务器
  • 原文地址:https://www.cnblogs.com/zhangchenliang/p/1635598.html
Copyright © 2020-2023  润新知