--创建、删除临时表
--第二种方式
select count(id) as storyNum,sum(convert(numeric(10,2),case when isnumeric(code)=1 then code else 0 end)) as codeNum,sum((case when isnumeric(realcode)=1 then convert(numeric(10,realcode) else 0.0 end)) as realcodeNum,tdtname,cycle,jiracomponent,jirastatename,qualityvalue,storycodellt
into #tmp from IKNOW_STORY_U2000V1R7C00 group by tdtname,storycodellt
--查询临时表
select * from #tmp
--删除临时表
if object_id('tempdb..#tmp') is not null
begin
drop table #tmp
end
SQL Server临时表的正确删除方式
删除SQL Server临时表和一般表并不相同,下面将为您为别示例错误和正确的删除操作,供您参考,希望对您能够有所帮助。
临时表与一般的表不同,它是保存到tempDb表中。临时表的表名与你所建的表名也不一样,因为他要为不同人的相同操作创建不同的临时表。
1、错误的删除操作:
2、正确的删除方式:
sql 判断临时表是否存在,删除临时表重建