Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010

    Unanswered: SQL Query update

    I have a ShipmentDetails table that stores the DateIn, DateOut, and AssetId for Assets stored in the asset table.

    I've created this query to update the ShipmentDetails DateIn column based on the AssetId and DateOut

    UPDATE       ShipmentDetails
    SET                DateIn = @DateIn
    WHERE        (AssetId = @AssetId) AND (DateOut = @DateOut)
    Asset, DateOut, DateIn
    30091,Oct 18 2010 8:50AM, Oct 31 2010 12:00 AM

    I need a query to update the DateIn code based on the AssetId and the DateOut. This works fine if I take the @DateOut part, but it updates every row with the asset 30091 and it shouldn't do that, It should only be updating one row since I only have one row with that AssetId AND DateOut.

    Soon as I add the @DateOut part back in it doesn't work. It never updates the DateIn WHERE AssetId = '30091' AND DateOut = 'Oct 31 2010 12:00 AM'

    Is there something wrong with that query?

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 11
    Your dateout has a time portion of 8:50 AM. If you set @DateOut to Oct 18 2010 8:50AM, you should get the single row updated.

  3. #3
    Join Date
    Sep 2010
    I think I got it. There seems to be an extra space between the year and the time that was throwing off my query. Don't know how I missed that! I added that space in there and now its working. Thanks for your reply MCrowley.

Posting Permissions

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