Q:

Return Number Of Records Updated

I am using C# to run a Sql Server stored procedure.   My syntax is as such
Update [silly]
Set [validname] = case 
                  when [Name] Not In ('BBABABA', 'SDLJK', 'KJSDJK') 
                  Then 'Yes' 
                  Else 'No' 
                  end
where [validname] IS NULL

Which of course when executed will return 5 rows updated or however many rows were updated.   Question being, is there a way for me to return to my C# syntax how many rows were updated with Yes and how many rows were updated with 'No'
I am using SQL Server 2008

A:

If you are using a newer version of SQL, you could use the OUTPUT clause, that would return a dataset that you could count the rows
Update [silly]
Set [validname] = case 
                  when [Name] Not In ('BBABABA', 'SDLJK', 'KJSDJK') 
                  Then 'Yes' 
                  Else 'No' 
                  end
Output inserted.validname
where [validname] IS NULL

EDIT
If you are looking to avoid iterating the results in .net I think you can  output the results into a temp table and then run a query on the temp table
DECLARE @temp TABLE (
      validname [varchar] NULL
    )

Update [silly]
Set [validname] = case 
                  when [Name] Not In ('BBABABA', 'SDLJK', 'KJSDJK') 
                    Then 'Yes' 
                    Else 'No' 
                  end
Output inserted.validname into @temp
where [validname] IS NULL

SELECT validname, count(*)
FROM @temp
GROUP BY validname

