日期:2014-05-18  浏览次数:20525 次

SQL求助
在B表中有兩個字段(Test,status)
在SQL中,如何將A表中TEST字段的值,填充到B表中TEST字段中,同時將status字段值都填充為"0"

------解决方案--------------------
试一下下面这个:感觉麻烦,不过效果不错.
declare cur cursor
read_only
for select Test from A 

declare @Test varchar(40)
declare @sql varchar(100)
open cur

fetch next from cur into @Test
while (@@fetch_status =0)
begin
insert into B (Test,status) values (@Test,0)
fetch next from cur into @Test
end

close cur
deallocate cur
go
------解决方案--------------------
insert into B (Test,status)
select Test, 0
from A
------解决方案--------------------
探讨
insert into B (Test,status)
select Test, 0
from A