Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts

    for each id run query

    Hi guys,

    i'm new to asp so this may seem easy to some people.

    but i have a variable called kal, which is a comma seperated list of id's, how can i run a query to update all records on an mssql db where the id's are equal to the ones listed in the variable kal.

    any help would great.

    thanks in advance.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    update tablename
    set fieldname = value
    where id in (1,2,3,4,5,6,7,8)
    I am the luckiest man in the world

  • #3
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts
    where you have the comma seperated values could i just simply put my varaible name in there?

  • #4
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Yes.

    strIds = "1,2,45,46"
    strSQL = "update tablename set fieldname = value where id in (" & strIds &")"


  •  

    Posting Permissions

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