首页 > 数据库技术 > 详细

sql server创建临时表的两种写法和删除临时表

时间:2021-06-16 14:31:55      阅读:19      评论:0      收藏:0      [点我收藏+]

--第一种方式

create table #tmp(name varchar(255),id int)
 
--第二种方式
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,2),realcode) else 0.0 end)) as realcodeNum,
tdtname,cycle,jiracomponent,jirastatename,qualityvalue,storycodellt
into #tmp from IKNOW_STORY_U2000V1R7C00 group by tdtname,cycle,jiracomponent,jirastatename,qualityvalue,storycodellt
 
--查询临时表
select * from #tmp
 
--删除临时表
if object_id(‘tempdb..#tmp‘) is not null
    begin
        drop table #tmp
    end

sql server创建临时表的两种写法和删除临时表

原文:https://www.cnblogs.com/skyay/p/14888790.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!