select UserID into #Test from dbo.User_Basic where UserID not in (select UserID from dbo.User_Detail)
declare my_cursor cursor
for
select UserID from #Test
open my_cursor
declare @UserID varchar(50)
fetch next from my_cursor into @UserID
while(@@fetch_status=0)
begin
insert into User_Detail(UserID) values(@UserID)
Print @UserID
fetch next from my_cursor into @UserID
end
close my_cursor
deallocate my_cursor
drop table #Test