sql - How to mark counted rows as deleted? contin'd from previous question -


Okay I realized that from my previous question:

To update this main table The method used to count using the secondary table, but since this query will be in a SQL job, how can I just delete the rows to count, and making sure I do not put any new lines in the secondary table?

If I am reading this, you (in your first question) with the number of unique IPs Records are associated with each employee who want to update the selection, and now in the same process the records come out from the list of those selections, which make those numbers - while no record was added since the selectioncount was updated. 1) is a primary key in your selection table, and And 2) A row line was created, so it would be very easy. The absence of both confused things.

So we will do it in a weird way (assuming you are unable to change your schema). Believes that you are using SQL 2005 or 2008:

I'm guessing my databases here

  DECLARE @TempIPs TABLE (EmployeeID int, ipaddress Varchar (25)) DELETE was removed from the selection output. EmployeeID, deleted in the @tempips.ap address  

- replace @TempIPs with reference to the selection table, which holds the legacy IP.

  Calculate Employee SET Selection = Ison ((SELECT Count (DISTINCT ipAddress) @TempIPs where @TempIPsEmployeeID = Employee.ID), 0)  

If you are planning to keep the Selectioncats added as a new record, just add the + SelectCancon in your UPDATE statement. You should wrap the whole lot inside the transaction (BEGIN transfer .... COMMIT TRANSACTION).


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -