A: 

In the video, your select goes like

and not IsAnnouncement = 1

wich gives entirely different results as in your update

and not (IsAnnouncement = 1)

It seems you are suffering from an operator precedence issue .

Edit

as the queries don't match in your video and although you say they have matched could you copy paste following script and let us know if or if they do not give you the same results? (I for one would have a hard time believing that the rows affected would differ)

begin tran

select * 
from tblBoardPost      
where 
  IdBoardPost = 1278    
  and IdAddress = 212787    
  and Subject = N'ttreterte'    
  and Banner is null    
  and UniqueSubject = N'ttreterte5'    
  AND (NOT ([IsAnnouncement] = 1))     
  AND (NOT ([IsSticky] = 1))     
  AND (NOT ([IsLocked] = 1))     
  and IsVisible = 1    
  and IdUserModified = 1    
  AND [IdNewsArticle] IS NULL    
  AND [IdList] IS NULL

update tblBoardPost    
  set IsSticky = 1
where 
  IdBoardPost = 1278    
  and IdAddress = 212787    
  and Subject = N'ttreterte'    
  and Banner is null    
  and UniqueSubject = N'ttreterte5'    
  AND (NOT ([IsAnnouncement] = 1))     
  AND (NOT ([IsSticky] = 1))     
  AND (NOT ([IsLocked] = 1))     
  and IsVisible = 1    
  and IdUserModified = 1    
  AND [IdNewsArticle] IS NULL    
  AND [IdList] IS NULL

rollback tran
Lieven
i've tried both. in fact, what was in the video was the code AFTER i tried the exact original code :(i've also tried adding many brackets all over the place .. still no luck.
Pure.Krome
Side note: when marking some text as code, SO seems to remove all empty lines. Very annoying. Probably there's an easy way to fix this in my formatting. If anyone knows, please let me know.
Lieven
Added image to opening post. First result is for the select statement. second result is the update (0 rows).
Pure.Krome
@Pure.Krome: I suggest you file a bug report with Microsoft. This obviously should not happen. As for your update, change it to update ... set ... where tblBoardPostUniqueID IN (select tblBoardPostUniqueID ...).
Lieven
I can write a simple stored procedure that only updates the field with the where clause on the PK instead. That's fine .. but that sql above is generated by Linq-to-Sql .. so i'm not sure if i can change it?? Also, if i add a new bug report with MS Connect, i have no idea how they can reproduce it, etc. I feel like it's a wasted effort. Unless there's an MS Sql guy here who's interested in RD'ing into my box to see the error ... ???? Anyone here have some contacts?
Pure.Krome
@Pure.Krome: trust me, you don't want me giving advice on Linq-to-Sql. My skills in that area are a bit limited and that's saying much. As for the reproducability, all that might be required is a script for that one table with indexes and data.
Lieven
if it's an index issue, is there anything I could do to check this? like .. disable all index's or something and then work back?
Pure.Krome
@Pure.Krome: anything is possible. If I would try to resolve it myself I would start with dropping all indexes one by one and trying the script after each index dropped and see if it makes a difference. If that's no help I would recreate the table in another database and try the script there. Try resolving it by eliminating every possible problem one by one until it works.
Lieven
good idea Lieven :) i'll start by doing that. I'll script all my index's first, then drop and go step by step.
Pure.Krome
@Pure.Krome: If you ever find out what went wrong, I would be very interested as to what it was.
Lieven
A: 

I checked your video, and you should try the same SQL conditions, that you used to return one row in your select query, in your update query. The conditions in the two SQL statements in your video aren't the same, and I don't really care why; they're not apples to apples.

Just copy and paste the working WHERE clause over the non-working one.

Robert Harvey
The video is excellent, by the way. You can see everything.
Robert Harvey
Originally, i did that. By the time i made the vid, i had some changes. But i swear when i use the same code, i get the same (bad) output :(
Pure.Krome
What indexes do you have? Make sure you have an indexed identity field as the Primary Key, and try it again. If that doesn't work, put a timestamp column in the table, and try it again. See http://msdn.microsoft.com/en-us/library/aa0416cz(VS.80).aspx for more information about how the timestamp is used.
Robert Harvey
i've got a number of index's on the query. The primary key does have a clustered index, with fill factor 80. It's 80% page fullness. 0% fragmented. I can grab a screenie if that helps?
Pure.Krome
Put a timestamp in the table, and let's see what Linq to SQL does with the SQL. My guess is that it will drop every field in the WHERE clause except for the primary key and the timestamp. The resulting query should work for your UPDATE.
Robert Harvey

related questions