实全软件科技有限公司

衡斅-衡量使人觉悟

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

/*定义临时变量*/

declare @Name nvarchar(20)

/*定义游标*/

declare Emp_Cursor cursor for

 

select LastName+' '+ FirstName from AdventureWorks.HumanResources.vEmployee

 

open Emp_Cursor

 

fetch next from Emp_Cursor into @Name

while(@@Fetch_Status = 0)

begin

    insert into DB_CRM.dbo.Tab_Employee(EmpName)values(@Name)

    fetch next from Emp_Cursor into @Name

end

close Emp_Cursor

/*删除游标引用*/

deallocate Emp_Cursor

Select * from DB_CRM.dbo.Tab_Employee

/*这次主要用于数据库升级!*/

posted on 2008-11-23 10:18  衡斅  阅读(431)  评论(0编辑  收藏  举报