判斷資料庫某欄位是否存在,判斷資料庫欄位

來源:互聯網
上載者:User

判斷資料庫某欄位是否存在,判斷資料庫欄位



本文由 書畫小說軟體 整理髮布 內容與本軟體無關 更愜意的讀、更舒心的寫、更輕鬆的發布



--判斷是否存在if exists(select 1 from master..sysdatabases where name='TestDB')    print 'TestDB存在'else    print 'TestDB不存在'        --判斷表是否存在if exists(select * from TestDB..syscolumns where id=object_id('TestDB.dbo.TestTb'))    print '表TestTb存在'else    print '表TestTb不存在'        --判斷資料中[TestTb]表中是否存在[Name]欄位if exists(select * from TestDB..syscolumns where id=object_id('TestDB.dbo.TestTb') and name='Name')    print '欄位Name存在'else    print '欄位Name不存在'



書畫小說軟體 製作更愜意的讀、更舒心的寫、更輕鬆的發布


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.