How to check if a column exists in a table in Sql Server 2008?

This question already has an answer here:

  • How to check if a column exists in a SQL Server table? 23 answers

  • 尝试这个:

    SELECT t.name as TabName
        ,c.name as ColName
    FROM sys.columns c 
    INNER JOIN sys.tables t on c.object_id = t.object_id
    WHERE c.name like '%COLUMN_NAME%'
        AND t.name = 'TABLE_NAME'
    
    链接地址: http://www.djcxy.com/p/94404.html

    上一篇: 如果它尚不存在,请将一列添加到表中

    下一篇: 如何检查一个列是否存在于Sql Server 2008的表中?