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 |
|
Dagaz
Starting Member
7 Posts |
Posted - 2004-11-22 : 12:56:39
|
| Hi I am new to T-SQL and can do stuff in asp but now need to use jobs to change data at set times, the following code is what i have in vb, any pointers in how to make it work in T-SQL would be appreciatedthanks DagazCode------>Randomize()Set RSFormUpd = Server.CreateObject("ADODB.Recordset")RSFormUpd.open "Select * From ViewWeeklyFormUpdate", Conn, 3, 3Do While Not RSFormUpd.EOFUpdForm = Round((int(RSFormUpd("StableHands"))/22) + (rnd * 2),0)If UpdForm = 0 Then If int(RSFormUpd("Form")) - 1 = 0 Then RSFormUpd("Form") = int(RSFormUpd("Form")) Else RSFormUpd("Form") = int(RSFormUpd("Form")) - 1 End IfEnd IfIf UpdForm = 1 ThenRSFormUpd("Form") = int(RSFormUpd("Form"))End IfIf UpdForm = 2 Then If int(RSFormUpd("Form")) + 1 = 6 Then RSFormUpd("Form") = int(RSFormUpd("Form")) Else RSFormUpd("Form") = int(RSFormUpd("Form")) + 1 End IfEnd IfResponse.write RSFormUpd("Form") & " "RSFormUpd.updateRSFormUpd.movenextLoopRSFormUpd.closeSet RSFormUpd = NothingDagaz |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-11-22 : 13:02:47
|
| can you tell us in psuedo-code what you are trying to do to the table? I understand physically what your VB code is doing, but I can't understand the logic of what this is accomplishing.- Jeff |
 |
|
|
Dagaz
Starting Member
7 Posts |
Posted - 2004-11-22 : 13:09:36
|
| hmm okhave a view which is a combination of TblHorses and TblOwners has fields:Form from HorsesStableHands from ownerslinked by Horses.OwnedBy = Owners.OwnerIDok goes through all the horses and creates a number either 0,1,2based on the formulaRound((int(RSFormUpd("StableHands"))/22) + (rnd * 2),0)then if the random number = 0 the Form goes down 1 unless is already 1 then stays the sameif = 1 then stays sameif = 2 then form goes up 1 unless it is already 5 then it stays the sameDagaz |
 |
|
|
|
|
|