请问如何得到sql server数据库其中一张表的表结构脚本?谢谢!

解决方案 »

  1.   

    //TTable,TTQuery
        for i := 0 to FieldDefs.Count - 1 do
        begin
          sTmp := FieldDefs.Items[i].Name;//DataType,Size,Required
      

  2.   

    SELECT b.*
    FROM sysobjects a,syscolumns b
    where a.id=b.id
    and a.name='表名'
      

  3.   

    select b.name AS 字段, 
        c.name as 数据类型 ,
        b.length as 长度, 
        case b.isnullable when 0 then 'not null' when 1 then 'null'end as 是否为空 
    from sysobjects a,syscolumns b,systypes c
    where a.name='表名' and a.id = b.id and b.usertype=c.usertype
    order by colid