/*定义临时变量*/
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
/*这次主要用于数据库升级!*/