--判断临时表是否存在
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#car') and type='U')
--删除临时表
DROP TABLE #car
--创建临时表
create table #car(
name nvarchar(20)
)
--将信息存入临时表
insert into #car
select
name from test
--Select * from #car --查询临时表的数据
--truncate table #car --清空临时表的所有数据和约束
--drop table #car
本文介绍如何使用SQL语句来判断临时表是否存在、创建临时表、插入数据、查询数据、清空数据以及删除临时表等基本操作。
8528

被折叠的 条评论
为什么被折叠?



