当前位置: 代码迷 >> SQL >> sql把临时表中的数据安插到另一个表中
  详细解决方案

sql把临时表中的数据安插到另一个表中

热度:85   发布时间:2016-05-05 13:27:02.0
sql把临时表中的数据插入到另一个表中
sql把临时表中的数据插入到另一个表中

1、把临时表中的数据插入到另一个表中

insert into 表 select * from #temp

2、把一个表中字段复制到临时表中

select * into #temp from?? 表 where 1=2

3、本地临时表的名称以单个数字符号 (#) 打头;它们仅对当前的用户连接是可见的;

4、当用户从 SQL Server 实例断开连接时被删除。

5、判断临时表是否存在

create proc temp(@tablename varchar(200))
as

begin
declare @exec varchar(8000)
set @exec='use tempdb
if exists(select * from sysobjects
where id=object_id(''tempdb..[email protected]+'''))
select ''存在''
else

select ''不存在'''
exec (@exec)

end

  相关解决方案