34,837
社区成员




declare @id varchar(200)
select @id=id FROM 表A where 网站名称='搜热网'
INSERT INTO 表B (网站名称,ID,地址) VALUES ('搜热网',@id,'http://soohot.com')
insert into 表B(网站名称,ID,地址)
select '搜热网',id,'http://soohot.com'
from 表A where 表A.网站名称='搜热网'
--单个ID
declare @id varchar(200)
select @id = top 1 id FROM 表A where 网站名称 = '搜热网'
if @id is not null
INSERT INTO 表B (网站名称 , ID , 地址) VALUES ('搜热网' , @id , 'http://soohot.com')
--多个ID
insert into 表B(网站名称 , ID , 地址)
select 网站名称 = '搜热网' , ID , 地址 = 'http://soohot.com' from A where 网站名称 = '搜热网'
declare @id varchar(200)
select @id = top 1 id FROM 表A where 网站名称 = '搜热网'
if @id is not null
INSERT INTO 表B (网站名称 , ID , 地址) VALUES ('搜热网' , @id ,'http://soohot.com')