Copyright@ ♂猜猜♂. 2005. All rights reserved.
--创建临时表
create table #t (
myid int not null,
mycd varchar(20) null
)
--删除临时表
declare @tmpTable nvarchar(300)
IF EXISTS(SELECT name
FROM tempdb..sysobjects
WHERE name like '#t'+'%'
AND type = 'U')
begin
set @tmpTable=''
set @tmpTable=(SELECT name FROM tempdb..sysobjects WHERE name like '#t'+'%' AND type = 'U')
exec('drop table '+@tmpTable)
end
GO
--说明
/*
临时表的命名规则:
#t 表示本地变量
##t 表示全局变量
*/
Copyright@ ♂猜猜♂. 2005. All rights reserved.