首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

能否给一个这样的存贮过程的例子?该如何处理

2012-02-16 
能否给一个这样的存贮过程的例子?从来没有写过proc,能否给一个下面的例子?1:判断临时表是否存在,有就dropt

能否给一个这样的存贮过程的例子?
从来没有写过proc,能否给一个下面的例子?

1:判断临时表是否存在,有就drop   table   #temp
2:从一个表里面取数据到临时表如(select   *   into   #temp   ),
3:然后对临时表进行操作(如:select   *   form   #temp)

[解决办法]
create proc proc1
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 #temp

go

热点排行
Bad Request.