表变量和临时表查询

--DECLARE @tb table( COUNTRYDESCRIPTION varchar(75),embi_global_index decimal(25, 5))
--Insert  @tb  select 'Argentina','1.24'

----select * from @tb

--Insert into embi_global( embi_global_index, country_code)
--select @tb.embi_global_index, RDSCOUNTRY.COUNTRYCODE
--from rdscountry join @tb on @tb.COUNTRYDESCRIPTION = rdscountry.COUNTRYDESCRIPTION

 

IF object_id('tempdb..#tb') IS NOT NULL
DROP TABLE #tb

CREATE TABLE #tb( COUNTRYDESCRIPTION varchar(75),embi_global_index decimal(25, 5)) ;
Insert  #tb  select 'Argentina','1.24'
select * from #tb

Insert into embi_global( embi_global_index, country_code)
select #tb.embi_global_index, RDSCOUNTRY.COUNTRYCODE
from rdscountry join #tb on #tb.COUNTRYDESCRIPTION = rdscountry.COUNTRYDESCRIPTION

posted @ 2012-08-22 13:48  China Soft  阅读(147)  评论(0编辑  收藏  举报