在存储过程中创建一临时表

来源:互联网 发布:编码器ssi数据位定义 编辑:程序博客网 时间:2024/06/02 18:03
create proc Aa
@age int
as
if object_id('tempdb.dbo.##test')isnull   ////////////****  判断临时表是否存在,存在就跳过,不存在就执行下面代码  ****/////////////

begin
create table tempdb.dbo.##test
(
age
int not null,
num
int not null
)
insert into ##test values(1,1)
end
else
begin
update ##testset age=@age
end
go

----------------------------------------
create proc getTest
as
select * from ##test
----------------------------------------
原创粉丝点击