Author |
Topic |
GaneshRamanan
Starting Member
40 Posts |
Posted - 2011-01-05 : 02:42:58
|
pls help me..create table #schedule (id int identity(1,1),fromtime datetime,appointmenttime datetime,totime datetime,status varchar(5))insert into #schedule (fromtime,appointmenttime,totime,status)select starttime,appointmenttime,endtime,'f' from opm.PanelDoctorDetail create table #scheduledetail(tokenno int identity(1,1), starttime datetime,appointment datetime,endtime datetime)declare @maxx intselect @maxx=MAX(id) from #schedule insert into #scheduledetail(tokenno,starttime,appointment,endtime)select @maxx+@tokenno,getdate(),getdate(),getdate() from #schedule i need to insert the values in the #scheduledetail table but the tokenno will be incremented from max(id) from #scheduleThanks,Ganesh |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-01-05 : 02:50:37
|
create table #scheduledetail(tokenno int, starttime datetime,appointment datetime,endtime datetime)now it should work.But maybe you really wantinsert into #schedule (fromtime,appointmenttime,totime,status)select starttime,appointmenttime,endtime,'f' from opm.PanelDoctorDetail select @maxx = scope_identity()insert into #scheduledetail(tokenno,starttime,appointment,endtime)select @maxx,getdate(),getdate(),getdate() from #schedule Not sure what you are trying to acheive with the @maxx+@tokenno.If it's just a sequence number on detail rows then it should be a separate column.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
GaneshRamanan
Starting Member
40 Posts |
Posted - 2011-01-05 : 03:17:12
|
Hi,I need to insert the values in #scheduledetail but the tokenno will be the max(id) from #schedule if suppose In #schedule table max(id)=68i need the tokenno will starts from 69 in scheduledetail tableThanks in advance. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-01-05 : 03:19:09
|
So you insert schedule 68detail 69, 70, 71next schedule = 69detail = 70, 71, ...duplicate ids in the detail table.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|