您的位置:首页 > 数据库

sql 表数据复制

2013-06-05 15:36 155 查看
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..'+@tablename+'''))

select ''存在''

else
select ''不存在'''

exec (@exec)
end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: