In the report Command, I use this code before populating a temp table:
IF OBJECT_ID('tempdb..#GROUPERS') IS NOT NULL
BEGIN
DROP TABLE #GROUPERS;
END;
When I save and run the command, I get this error message:
How can I resolve this?
答案 0 :(得分:1)
当我跑步时,我得到它不存在
create table #GROUPERS(i1 int)
IF OBJECT_ID('tempdb..#GROUPERS') IS NOT NULL
BEGIN
DROP TABLE #GROUPERS;
END;
if OBJECT_ID('tempdb..#GROUPERS') IS NOT NULL
print 'It exists'
else
print 'It does not exist'
这意味着逻辑有效。我愿意打赌if语句所在的行上有一个不可打印的字符(不可见字符)。你从某个地方剪切并粘贴了这段代码吗?尝试单击错误消息。它可能会带你到错误的位置。在行尾可能有奇怪的字符......
答案 1 :(得分:1)
取出代码中的所有CTE。不确定为什么