SQL Server 覚書

sqlcmd -U ユーザ -P パスワード -S サーバ -d データベース -Y 画面幅を文字数で指定 -q "SET IMPLICIT_TRANSACTIONS ON;"

-- cat (tableのみ)
select name, id, xtype, uid, type from sysobjects where xtype ='U'

-- desc (テーブルのidを指定する)
select name, xtype, length, colid, domain, status, type, isnullable
  from syscolumns
 where id = 9999999999
 order by colorder

-- index (テーブルのidを指定する)
select i1.name, c1.name
  from sysindexes i1,
       sysindexkeys k1,
       syscolumns c1
 where i1.id = k1.id
   and i1.indid = k1.indid
   and k1.id = c1.id
   and k1.colid = c1.colid
   and i1.id = 9999999999
 order by i1.indid, k1.keyno