﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by fediori  / Using a TSQL semaphore in SSIS / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 26 May 2013 03:22:20 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Using a TSQL semaphore in SSIS</title><link>http://www.sqlservercentral.com/Forums/Topic1406572-2632-1.aspx</link><description>[quote][b]Henry B. Stinson (1/14/2013)[/b][hr]Two problems I see right off:1. You may not want isolation level serializable for the whole package.  That may cause unnecessary blocking in other processes.[/quote]I suppose you are rigth , I should be enough to set isolation level serializable for the single components[quote]2. if the data flow fails, the semaphore is not released.[/quote]If the data flow fails, the semaphore is released . The semaphore is designed in such a way, that cannot remain unreleased if the session terminates The semaphore is acquired by putting a lock on a row :  begin tran select * from drop_fi_semaforo with ( rowlock, UPDLOCK, holdlock)   where Uno = '1'There is nothing to commit or rollback , since data are not modified . If the session is terminated, the lock is released, the DBMS takes care of it </description><pubDate>Tue, 15 Jan 2013 02:09:35 GMT</pubDate><dc:creator>Federico Iori</dc:creator></item><item><title>RE: Using a TSQL semaphore in SSIS</title><link>http://www.sqlservercentral.com/Forums/Topic1406572-2632-1.aspx</link><description>[quote][b]Cade Roux (1/13/2013)[/b][hr]Any particular reason that sp_getapplock wasn't used for this implementation?http://msdn.microsoft.com/en-us/library/ms189823.aspx[/quote]Thanks for pointing this out...  My predecessor used a data update of all rows with a fake column value to get around this and the whole thing was a nasty can of worms.  sp_getapplock is so clean!</description><pubDate>Mon, 14 Jan 2013 12:00:24 GMT</pubDate><dc:creator>SAinCA</dc:creator></item><item><title>RE: Using a TSQL semaphore in SSIS</title><link>http://www.sqlservercentral.com/Forums/Topic1406572-2632-1.aspx</link><description>Two problems I see right off:1. You may not want isolation level serializable for the whole package.  That may cause unnecessary blocking in other processes.2. if the data flow fails, the semaphore is not released.</description><pubDate>Mon, 14 Jan 2013 08:56:56 GMT</pubDate><dc:creator>Henry B. Stinson</dc:creator></item><item><title>RE: Using a TSQL semaphore in SSIS</title><link>http://www.sqlservercentral.com/Forums/Topic1406572-2632-1.aspx</link><description>Release the semaphore : just end the transaction that is holding the semaphore by a commit ( or rollback, is the same since no data are modified) ...</description><pubDate>Mon, 14 Jan 2013 06:02:14 GMT</pubDate><dc:creator>Federico Iori</dc:creator></item><item><title>RE: Using a TSQL semaphore in SSIS</title><link>http://www.sqlservercentral.com/Forums/Topic1406572-2632-1.aspx</link><description>Thanks for the post. A useful addition would be how to release the semaphore from within the package. A fairly common use case is to have a queue and want to hold the semaphore while you are selecting the next item from the queue. Ill also check out spappLockThanks again.</description><pubDate>Mon, 14 Jan 2013 05:58:55 GMT</pubDate><dc:creator>greg 15422</dc:creator></item><item><title>RE: Using a TSQL semaphore in SSIS</title><link>http://www.sqlservercentral.com/Forums/Topic1406572-2632-1.aspx</link><description>Yes, you are right, built-in  sp_getapplock could be used in my solution instead of the user-defined semaphore table  drop_fi_semaphore, but the structure of the SSIS package would remain unchanged .The only changed block will be Get Semaphore .</description><pubDate>Mon, 14 Jan 2013 02:50:32 GMT</pubDate><dc:creator>Federico Iori</dc:creator></item><item><title>RE: Using a TSQL semaphore in SSIS</title><link>http://www.sqlservercentral.com/Forums/Topic1406572-2632-1.aspx</link><description>Any particular reason that sp_getapplock wasn't used for this implementation?http://msdn.microsoft.com/en-us/library/ms189823.aspx</description><pubDate>Sun, 13 Jan 2013 22:54:31 GMT</pubDate><dc:creator>Cade Roux</dc:creator></item><item><title>Using a TSQL semaphore in SSIS</title><link>http://www.sqlservercentral.com/Forums/Topic1406572-2632-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/articles/T-SQL/93759/"&gt;Using a TSQL semaphore in SSIS&lt;/A&gt;[/B]</description><pubDate>Sun, 13 Jan 2013 22:50:05 GMT</pubDate><dc:creator>Federico Iori</dc:creator></item></channel></rss>