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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Convert VB to T-SQL

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 appreciated

thanks

Dagaz

Code------>

Randomize()

Set RSFormUpd = Server.CreateObject("ADODB.Recordset")
RSFormUpd.open "Select * From ViewWeeklyFormUpdate", Conn, 3, 3
Do While Not RSFormUpd.EOF

UpdForm = 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 If
End If

If UpdForm = 1 Then
RSFormUpd("Form") = int(RSFormUpd("Form"))
End If

If UpdForm = 2 Then
If int(RSFormUpd("Form")) + 1 = 6 Then
RSFormUpd("Form") = int(RSFormUpd("Form"))
Else
RSFormUpd("Form") = int(RSFormUpd("Form")) + 1
End If
End If

Response.write RSFormUpd("Form") & " "

RSFormUpd.update

RSFormUpd.movenext
Loop

RSFormUpd.close
Set RSFormUpd = Nothing


Dagaz

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
Go to Top of Page

Dagaz
Starting Member

7 Posts

Posted - 2004-11-22 : 13:09:36
hmm ok

have a view which is a combination of TblHorses and TblOwners has fields:

Form from Horses
StableHands from owners

linked by Horses.OwnedBy = Owners.OwnerID

ok goes through all the horses and creates a number either 0,1,2

based on the formula

Round((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 same

if = 1 then stays same

if = 2 then form goes up 1 unless it is already 5 then it stays the same

Dagaz
Go to Top of Page
   

- Advertisement -