首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-05-05 
查询表是否存在的问题泪奔。。。SQL codeexec(if(object_id(##tableName,u) is not null)begintruncate

查询表是否存在的问题
泪奔。。。

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') 

热点排行