从来没有写过proc,能否给一个下面的例子?1:判断临时表是否存在,有就drop table #temp
2:从一个表里面取数据到临时表如(select * into #temp ),
3:然后对临时表进行操作(如:select * form #temp)
2:从一个表里面取数据到临时表如(select * into #temp ),
3:然后对临时表进行操作(如:select * form #temp)
调试欢乐多
as
if exists (select * from temp.dbo.sysobjects where id = object_id(N'temp.dbo.[#temp]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [#temp]
select * into #temp from ...
select * form #tempgo
as
if exists (select * from tempdb.dbo.sysobjects
where id = object_id(N'tempdb.dbo.[#temp]')
and type='u'
)
drop table [#temp]
select * into #temp from ...
select * form #tempgo