Thursday, November 28, 2013

Test your JavaScript and send the sample to other

http://jsfiddle.net/

Cool Site!

Sql Testing with various DB Engines

http://sqlfiddle.com

You can test various database and send samples to others!
We got to love this!

Tuesday, October 15, 2013

How to backup/restore reports from Sql Server Reporting Services or create a deploy/installer

https://sqlserverfinebuild.codeplex.com/wikipage?title=Install%20Reporting%20Services%20Scripter

These small tool is very useful when handling Reports.
What these tool does, is backup the reports in a form that can be easily deploy in any server.

Monday, September 16, 2013

The only .net profiler that works how it is suposed

http://www.yourkit.com/

Try it! It is a must have dev tool. You can use it for tracking:
memory leaks, high cpu usage, check SQL commands....

Friday, September 06, 2013

Dispatcher with database deadlock (or using queue with multiple workers)

I have a web service with the following set of operations:
-insert event
-get all available events
-send the events
-mark as sended

It's easy to generate a deadlock with this sequence, so what we need to do is use the sql hints to handle this matter.

BEGIN TRAN


--INSERT A NEW ELEMENT LOCKING ONLY THE INSERTED ROW
INSERT INTO  [Tab1] WITH (ROWLOCK)
           ([objectTypeId]
           ,[objectId] )
     VALUES
           (8
           ,1)

--SELECT THE EVENTS AVOIDING SELECTING THE BLOCKED ROWS (READPAST)
SELECT * FROM [Tab1] WITH  (READPAST, ROWLOCK)
     WHERE objectTypeId = 8 AND objectId =1

--UPDATE ALL THE EVENTS THAT WE NEED, ALL THE UNLOCKED ONES
UPDATE [Tab1] with (READPAST, ROWLOCK)
     SET operationTms = GETDATE()
     WHERE objectTypeId = 8  AND objectId =1


COMMIT

"As a last note, the READPAST hint can only be specified in transactions operating at the READ COMMITTED or REPEATABLE READ isolation levels." in http://aartemiou.blogspot.pt/2011/08/updating-sql-server-tables-without.html