当前位置: 代码迷 >> Sql Server >> 查询表是否存在的有关问题
  详细解决方案

查询表是否存在的有关问题

热度:29   发布时间:2016-04-27 13:01:43.0
查询表是否存在的问题
泪奔。。。

SQL code
exec('    if(object_id('##tableName','u') is not null)    begin       truncate '##tableName'    end    else    begin       create table ##tableName       (           whID,int       )    end')


这里明显有错!单引号嵌套!
但是,要怎么修改才能正确啊???
在线等解答。

------解决方案--------------------
SQL code
exec('    if(object_id(''##tableName'',''u'') is not null)    begin       truncate table ##tableName    end    else    begin       create table ##tableName       (           whID int       )    end')
  相关解决方案