用C#代码实现将同一个SQL2008数据库中一个表的信息导入另同样字段的表 高手帮忙!
展开全部
看看这段游标的代码,看是否能给你一定的启发
declare MyTestCursor cursor
for select memb_id,memb_name from cm_member
/*从表中选取两个字段*/
/* 表TBLPRICELISTGROUPITEM中的字段PGI_ITM_CODE是Unique Key */
-- 打开游标MyTestCursor:
open MyTestCursor
declare @memb_id int
declare @memb_name nvarchar(50)
--fetch取出游标所指的记录,并将记录结果存入到变量中:
fetch from MyTestCursor into @memb_id,@memb_name
/***************** begin of loop *******************************/
while @@FETCH_STATUS = 0
Begin
update cm_ycpoetic set memb_id=@memb_id where author=@memb_name
fetch next from MyTestCursor into @memb_id,@memb_name
End
/***************** end of loop *******************************/
select @memb_id as code ,@memb_name as price
/***********关闭游标,释放游标:***************/
close MyTestCursor
deallocate MyTestCursor
declare MyTestCursor cursor
for select memb_id,memb_name from cm_member
/*从表中选取两个字段*/
/* 表TBLPRICELISTGROUPITEM中的字段PGI_ITM_CODE是Unique Key */
-- 打开游标MyTestCursor:
open MyTestCursor
declare @memb_id int
declare @memb_name nvarchar(50)
--fetch取出游标所指的记录,并将记录结果存入到变量中:
fetch from MyTestCursor into @memb_id,@memb_name
/***************** begin of loop *******************************/
while @@FETCH_STATUS = 0
Begin
update cm_ycpoetic set memb_id=@memb_id where author=@memb_name
fetch next from MyTestCursor into @memb_id,@memb_name
End
/***************** end of loop *******************************/
select @memb_id as code ,@memb_name as price
/***********关闭游标,释放游标:***************/
close MyTestCursor
deallocate MyTestCursor
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询