sql插入--从其他表插入另一张

Declare @orgName varchar(40)
Select @orgName=Name From Organization Where ID=161

 


insert into ScoreOrgCorrespond(OrgID,OrgName,ScoreOrgID,ScoreOrgName,ScoreTypeID,ScoreOrgType,IsDeleted)
select T1.ID As OrgID,T1.Name As OrgName,161 As ScoreOrgID,@orgName As ScoreOrgName,2 As ScoreTypeID,2 As ScoreOrgType,0 As IsDeleted from (select ID,Name from dbo.Organization where DisplayParentID in(300,301,335) and IsDeleted=0 and Name not in('安徽代表处',
'江苏代表处',
'四川代表处'
)) As T1

posted @ 2012-12-05 13:36  Eiffel——*  阅读(184)  评论(0编辑  收藏  举报