求教判断临时表存在的SQL语句。。。。急

fbilibf 2005-06-28 11:49:45
我建立了一个#Report临时表,,现在我想判断它是否存在,,,,该怎么做?
...全文
533 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
fbilibf 2005-06-29
  • 打赏
  • 举报
回复
在问一个傻的问题。。。(马上给分)
我要从表Department把所有的记录COPY到#Report临时表中,,我这样的写法错的哪里,怎么改?
insert into ##Report select(DepNo,DepName,Remark)Form Department
lxd99423 2005-06-29
  • 打赏
  • 举报
回复
select 1 from tempdb..sysobjects where name like '#Report%'
U2U2U2U2 2005-06-29
  • 打赏
  • 举报
回复

--1.第一个问题关于查出是否有某个临时表
select * from master..sysobjects where id=object_id('临时表名')

--2.把你的数据插入到临时表中,记得你的列名必须一致
insert into #Report select DepNo,DepName,Remark Form Department
wangdehao 2005-06-29
  • 打赏
  • 举报
回复
insert into ##Report select DepNo,DepName,Remark Form Department
这个是全局临时表
并且此临时表必须已经建立
WZZ 2005-06-29
  • 打赏
  • 举报
回复
IF OBJECT_ID('tempdb..#Report') IS NOT NULL DROP TABLE #Report
Navywang917 2005-06-29
  • 打赏
  • 举报
回复
insert into #Report select DepNo,DepName,Remark Form Department
xiaoxiangqing 2005-06-29
  • 打赏
  • 举报
回复
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#Report'))
select '#Report表存在!'
else
select '#Report表不存在!'
yesyesyes 2005-06-29
  • 打赏
  • 举报
回复
insert into #Report select DepNo,DepName,Remark Form Department
osso911 2005-06-29
  • 打赏
  • 举报
回复
看看先

27,581

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧