您好,欢迎访问一九零五行业门户网

判断数据库某字段是否存在

--判断是否存在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
--判断是否存在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不存在'
其它类似信息

推荐信息