MSSQL 判断实例中是否存在某种表

执行语句

SELECT 'SELECT * FROM '+Name+'..SysObjects Where XType=''U'' and name=''tab_scartrim'' ORDER BY Name' FROM Master..SysDatabases ORDER BY Name

生成如下语句
SELECT * FROM ********************..SysObjects Where XType='U' and name='tab_scartrim' ORDER BY Name
SELECT * FROM ********************..SysObjects Where XType='U' and name='tab_scartrim' ORDER BY Name
SELECT * FROM ********************..SysObjects Where XType='U' and name='tab_scartrim' ORDER BY Name

进行二次查询就能知道什么数据库存在表了

上一篇:struts 2 --SEVERE: Could not find action or result


下一篇:11个超棒的iOS开发学习网站