有没有办法在SQL Server中使用T-SQL读取计算列的公式?
我试过以下但是不起作用:
SELECT
COLUMN_NAME,
COLUMNPROPERTY(OBJECT_ID(TABLE_NAME), COLUMN_NAME, 'Formula')
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME = 'Tablename'
答案 0 :(得分:1)
CREATE TABLE FormulaTable(i INT ,j INT ,k AS i*j+10)
SELECT cc.definition
FROM sys.computed_columns AS cc
WHERE cc.name='k'
输出:
definition
-------------------------------------
([i]*[j]+(10))