2009-07-13 46 views
2

夥計們,我正在使用SQL Server 2000並執行sp_columns存儲過程來獲取我的表的佈局。我的一個領域是一個公式領域,我的問題是,我怎麼能通過sp_columns確定這一點? sp_columns似乎不顯示此信息。確定公式字段

在此先感謝

回答

2

,你可以放棄SP_COLUMNS到一個臨時表的結果,然後在ColumnProperty函數添加到的,結果...

create table #results(
    TABLE_QUALIFIER sysname, 
    TABLE_OWNER sysname, 
    TABLE_NAME sysname, 
    COLUMN_NAME sysname, 
    DATA_TYPE smallint, 
    TYPE_NAME sysname, 
    PRECISION int, 
    LENGTH int, 
    SCALE smallint, 
    RADIX smallint, 
    NULLABLE smallint, 
    REMARKS varchar(254), 
    COLUMN_DEF nvarchar(4000), 
    SQL_DATA_TYPE smallint, 
    SQL_DATETIME_SUB smallint, 
    CHAR_OCTET_LENGTH int, 
    ORDINAL_POSITION int, 
    IS_NULLABLE varchar(254), 
    SS_DATA_TYPE tinyint) 

insert #results 
exec sp_columns 'MyTable' 

select IsComputed = ColumnProperty(object_id(table_owner + '.' + table_name), column_name, 'IsComputed'), 
     * 
from #results 
1
SELECT name FROM syscolumns where id IN(
SELECT ID FROM sysobjects where name = 'My Table' and xtype ='U') 
and IsComputed = 1 

拉吉