首页 > 数据库技术 > 详细

sql 临时表

时间:2016-08-14 22:14:50      阅读:256      评论:0      收藏:0      [点我收藏+]

update Company set TFN=null where TFN=‘-2147483648‘
update Application set CompanyTFN=null where CompanyTFN=-2147483648

UPDATE Company set TFN=null where CAST(TFN as int)<0
UPDATE Application set CompanyTFN=null WHERE CompanyTFN<0


select object_id from sys.columns where name like ‘%HIN%‘
select * from sys.tables where object_id in (select object_id from sys.columns where name like ‘%HIN%‘)

 


/////////////////////////////////////////////////////////////////////////////////////////////////


drop table #Tmp
create table #TMP
(
ID int IDENTITY (1,1) not null, --创建列ID,并且每次新增一条记录就会加1
deptId int,
deptName varchar(50),
dataTimes datetime
primary key (ID) --定义ID为临时表#Tmp的主键
);

insert into #TMP Exec DEPTDisplay ‘果丹皮‘,5

select id,
(case deptId when ‘5‘ then ‘HAHA‘
when ‘4‘ then ‘NoNo‘
else ‘Yeye‘
end
) as Ids,
deptid,deptName,(select DATEADD(q,1,ISNULL(dataTimes,‘1900-2-3‘))) as tt from #TMP


declare @TempGroup table ( ID int,deptName varchar(50),dataTimes datetime)
insert into @TempGroup Exec DEPTDisplay ‘果丹皮‘,5
select id,
(case id when ‘5‘ then ‘HAHA‘
when ‘4‘ then ‘NoNo‘
else ‘Yeye‘
end
) as Ids,
id,deptName,(select DATEADD(q,1,ISNULL(dataTimes,‘1900-2-3‘))) from @TempGroup
union all
select id,
(case id when ‘5‘ then ‘HAHA‘
when ‘4‘ then ‘NoNo‘
else ‘Yeye‘
end
) as Ids,
id,deptName,(select DATEADD(q,1,ISNULL(dataTimes,‘1900-2-3‘))) from @TempGroup
select distinct * from @TempGroup

/////////////////////////////////////////////////////////////////////////////////////////////////

 

sql 临时表

原文:http://www.cnblogs.com/xiaotank/p/5771142.html

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