--第一种方式
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
--错误的临时表删除操作,因为所在数据库不同 IF EXISTS (SELECT * FROM sysobjects WHERE object_id = OBJECT_ID(N'[dbo].[#tempTable]') AND type in (N'U')) Begin DROP TABLE [dbo].[tempTable] End --错误的临时表删除操作,因为临时表名已变 if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'[#temptable]')) Begin drop table #temptable End
--正确的临时表删除操作
if object_id('tempdb..#tempTable') is not null Begin
drop table #tempTable
End
IF Object_id('Tempdb..#dl') IS NOT NULL
DROP TABLE #dl --如果有存在就删除临时表
CREATE TABLE #dl (neirong char(20),icount int, dlzonjine int, dlshu int, dlyin int) --重建临时表
INSERT INTO #dl SELECT * FROM tab1 --把物理表的数据插到临时表
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有