HP 1010 Shared from Debian via CUPS to OSX

The print server is on a different subnet to the print clients, so liberal sprinklings of ‘Allow All’ throughout the cupsd.conf file makes the webui ‘servername:631’ accessible from clients.

Use the server’s webui to add the USB connected local printer (the HP Laserjet 1010). Select ‘Share this printer’ and ensure that sharing is enabled in the server’s cupsd.conf file.

Add a ‘BrowsePoll servername:631’ line and a ‘BrowseRemoteProtocols cups’ line to the client’s cupsd.conf file to coerce the client to poll the remote server for printers.

Using the client’s webui, the printer should automatically show up within 30 seconds according to the fine manual.

TSQL Soft Delete

Ever needed to delete several million rows from a database ‘in the background’?

Just running a delete statement would lock the table, preventing any users from writing to it… It would also fill up your transaction log quite rapidly…

So why not batch it into chunks of 1000 and run each in its own transaction. Combined with an optional delay between batches, hardly anyone will notice all those deletions!

Declare CurToDelete Cursor For 

    Select top 9000 LoggingId from Logging 
        where foo like 'bar'

for read only

Open CurToDelete
Declare @DeleteThisId int
Fetch Next From CurToDelete Into @DeleteThisId


    declare @DeleteList table
        id int

    -- Delete in batches of 1000, then pause
    declare @batchsize int
    set @batchsize = 1000
    declare @havedeleted int
    set @havedeleted = 0

   -- put the next 1000 IDs into a TEMP table
    while (@havedeleted<=@batchsize) and @@FETCH_STATUS = 0 

       print cast(@DeleteThisId as varchar)

       insert into @DeleteList values ( @DeleteThisId )

       Fetch Next From CurToDelete Into @DeleteThisId

       set @havedeleted=@havedeleted+1
        --print @havedeleted    


    -- Actually do the deletion
    Begin Transaction

    delete from Logging 
        where LoggingID in (select ID from @DeleteList)
    -- clear the TEMP table
    delete from @DeleteList

    Commit Transaction

    -- Optional Delay
    --print 'waiting for 10...'
    --WaitFor Delay '00:00:10'


Close CurToDelete
deallocate CurToDelete