Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sravz
Starting Member
42 Posts |
Posted - 2011-04-22 : 16:21:32
|
| Hi Every one,I am trying to solve this Issue.I had a table with these values ID_File| PartNumber(varchar) |TCHours(Decimal)| POHours(Decimal)345 | this week schedule | 2.00 | 1.00345 | No Perm reqd | 2.00 | 0.80348 | The flight expenses|1.80 | 0.00394 | 0 | 0.00 | 0.00 I Need to update the data automatically when user clicks updatewhat needs to be updated are only the single Records Id here(348,394) only when TcHours is 0.00 update PoHours to 1.00Else when TCHours>0.00 then Update POHours to TCHoursIn this case I wrote a cursor its working fine but giving this error.and updating only 5 records Time out expired.when I click update again ,it repeats the same process.If there is any other type of updating process please let me know.Or If I can remove the error please let me know.Thanks in Advance |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
sravz
Starting Member
42 Posts |
Posted - 2011-04-25 : 09:30:58
|
| Hey tara,Thanks for the reply.Okay I had one more question ID_File| PartNumber(varchar) |TCHours(Decimal)| POHours(Decimal)345 | this week schedule | 2.00 | 1.00345 | No Perm reqd | 2.00 | 0.80348 | The flight expenses|1.80 | 0.00394 | 0 | 0.00 | 0.00In the above table what if i want to get the records with Single ID(Eg:ID=348,394,....) into an temp table.What is the query I can write.Please help me.Thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-04-25 : 09:37:34
|
| select t1.* from table as t1 inner join (select ID_file from table group by ID_file having count(ID_File)=1) as t2 on t1.ID_File=t2.ID_FileMadhivananFailing to plan is Planning to fail |
 |
|
|
sravz
Starting Member
42 Posts |
Posted - 2011-04-25 : 09:46:39
|
| Hey Madhivanan,Thanks for the immediate reply.It worked but I want to put the result set in a temp table.I am new to sql So can u please let me know how to do that?and also can u explain how u had done the above query.I just want to learn |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-04-25 : 09:52:54
|
| select t1.* into #temp from table as t1 inner join (select ID_file from table group by ID_file having count(ID_File)=1) as t2 on t1.ID_File=t2.ID_FileThe code select ID_file from table group by ID_file having count(ID_File)=1 gets rows with only single occurance of ID_FileMadhivananFailing to plan is Planning to fail |
 |
|
|
sravz
Starting Member
42 Posts |
Posted - 2011-04-25 : 10:15:25
|
| Thanks Madhivanan,Good to know.Got to know how to write the result set into temp table.Thanks,Sravanthi |
 |
|
|
|
|
|
|
|