Code:
Declare @Charid INT Declare charq cursor for select distinct charid from _Char where CharID !=0 open charq fetch next from charq into @CharID while @@FETCH_STATUS =0 BEGIN Insert into _CharQuest (CharID,QuestID,Status,AchievementCount,StartTime,EndTime,QuestData1,QuestData2) Values (@charid,1,5,0,'2013-07-16 18:35:00','2013-07-16 18:35:00',8388691,0) Insert into _CharQuest (CharID,QuestID,Status,AchievementCount,StartTime,EndTime,QuestData1,QuestData2) Values (@charid,2,1,0,'2013-07-16 18:35:00','2013-07-16 18:35:00',8388691,0) Insert into _CharQuest (CharID,QuestID,Status,AchievementCount,StartTime,EndTime,QuestData1,QuestData2) Values (@charid,385,8,0,'2013-07-16 18:35:00','2013-07-16 18:35:00',0,0) Insert into _CharQuest (CharID,QuestID,Status,AchievementCount,StartTime,EndTime,QuestData1,QuestData2) Values (@charid,386,8,0,'2013-07-16 18:35:00','2013-07-16 18:35:00',16842753,0) Insert into _CharQuest (CharID,QuestID,Status,AchievementCount,StartTime,EndTime,QuestData1,QuestData2) Values (@charid,387,8,0,'2013-07-16 18:35:00','2013-07-16 18:35:00',16842753,0) Insert into _CharQuest (CharID,QuestID,Status,AchievementCount,StartTime,EndTime,QuestData1,QuestData2) Values (@charid,388,8,0,'2013-07-16 18:35:00','2013-07-16 18:35:00',16842753,0) Insert into _CharQuest (CharID,QuestID,Status,AchievementCount,StartTime,EndTime,QuestData1,QuestData2) Values (@charid,389,8,0,'2013-07-16 18:35:00','2013-07-16 18:35:00',16842753,0) Insert into _CharQuest (CharID,QuestID,Status,AchievementCount,StartTime,EndTime,QuestData1,QuestData2) Values (@charid,397,8,0,'2013-07-16 18:35:00','2013-07-16 18:35:00',16777217,0) fetch next from charq into @charid END close charq deallocate charq