Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    2

    Unanswered: New to T-SQL, some pointers please

    hmm ok here is an outline:

    I 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


    then this is how i coded in asp as i can do asp/vb programming lol but T-SQL is a mystery:

    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

    Thanks in advance

    Dagaz

  2. #2
    Join Date
    May 2003
    Location
    UK
    Posts
    220
    so what is the problem please?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •