<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type='text/xsl' href='http://briankramp.spaces.live.com/mmm2008-07-24_12.50/rsspretty.aspx?rssquery=en-US;http%3a%2f%2fbriankramp.spaces.live.com%2fcategory%2fCode%2bSnippets%2ffeed.rss' version='1.0'?><rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:msn="http://schemas.microsoft.com/msn/spaces/2005/rss" xmlns:live="http://schemas.microsoft.com/live/spaces/2006/rss" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Investing Journal: Code Snippets</title><description /><link>http://briankramp.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&amp;_c=BlogPart&amp;partqs=catCode%2bSnippets</link><language>en-US</language><pubDate>Sun, 17 Aug 2008 02:23:57 GMT</pubDate><lastBuildDate>Sun, 17 Aug 2008 02:23:57 GMT</lastBuildDate><generator>Microsoft Spaces v1.1</generator><docs>http://www.rssboard.org/rss-specification</docs><ttl>60</ttl><cf:parentRSS>http://briankramp.spaces.live.com/blog/feed.rss</cf:parentRSS><live:type>blogcategory</live:type><live:identity><live:id>-341918060925026325</live:id><live:alias>briankramp</live:alias></live:identity><cf:listinfo><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="typelabel" label="Type" /><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="tag" label="Tag" /><cf:group element="category" label="Category" /><cf:sort element="pubDate" label="Date" data-type="date" default="true" /><cf:sort element="title" label="Title" data-type="string" /><cf:sort ns="http://purl.org/rss/1.0/modules/slash/" element="comments" label="Comments" data-type="number" /></cf:listinfo><item><title>Using Directory Services to find if a user belongs to a group - nested scenario.</title><link>http://briankramp.spaces.live.com/Blog/cns!FB414355CC45FFEB!354.entry</link><description>&lt;div&gt;Hard to believe I spent so much time searching for this, but it took forever, so I decided to create a link to the site that eventually helped me.  I use a tool that searches MSN Search and Google side-by-side and MSN is the one that finally came up with it.&lt;/div&gt;
&lt;div&gt;&lt;font color="#004377"&gt;&lt;a href="http://www.irishdev.com/blogs/jbrennan/archive/2004/11/17/292.aspx"&gt;http://www.irishdev.com/blogs/jbrennan/archive/2004/11/17/292.aspx&lt;/a&gt;&lt;a href="http://www.irishdev.com/blogs/jbrennan/archive/2005/01/26/441.aspx"&gt;&lt;/a&gt;&lt;/font&gt;&lt;a href="http://www.irishdev.com/blogs/jbrennan/archive/category/1002.aspx"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The main problem I was having is that none of the examples I found treated the nested group scenario.  Where a user belongs to a group through membership in another group.  The trick is to use the &amp;quot;tokenGroups&amp;quot; property to return all the SIDs for groups the user is a member of.  Then compare it to the SID for the group you're interested in.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-341918060925026325&amp;page=RSS%3a+Using+Directory+Services+to+find+if+a+user+belongs+to+a+group+-+nested+scenario.&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=briankramp.spaces.live.com&amp;amp;GT1=briankramp"&gt;</description><comments>http://briankramp.spaces.live.com/Blog/cns!FB414355CC45FFEB!354.entry#comment</comments><guid isPermaLink="true">http://briankramp.spaces.live.com/Blog/cns!FB414355CC45FFEB!354.entry</guid><pubDate>Tue, 10 Jan 2006 17:32:12 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://briankramp.spaces.live.com/blog/cns!FB414355CC45FFEB!354/comments/feed.rss</wfw:commentRss><wfw:comment>http://briankramp.spaces.live.com/Blog/cns!FB414355CC45FFEB!354.entry#comment</wfw:comment><dcterms:modified>2006-01-10T17:32:12Z</dcterms:modified></item><item><title>Delete duplicate SQL rows</title><link>http://briankramp.spaces.live.com/Blog/cns!FB414355CC45FFEB!266.entry</link><description>&lt;p&gt;The code to delete exactly duplicate rows in SQL is somewhat tricky.  The fastest way is to perform a select distinct into a temporary table, and then reinsert them back.  The code below is nice because it touches only the rows that are duplicated, but it will be slow if you have a lot of duplicates.  Especially because deletes are costly operations.
&lt;p&gt;&lt;font face="Courier New, Courier, Monospace"&gt;DECLARE @switch int&lt;br&gt;SET @switch = 0&lt;/font&gt;
&lt;p&gt;&lt;font face="Courier New, Courier, Monospace"&gt;--This statement causes SQL to delete 1 row at a time.&lt;br&gt;--This leaves one of the dulpicate rows remaining.&lt;br&gt;SET rowcount 1&lt;/font&gt;
&lt;p&gt;&lt;font face="Courier New, Courier, Monospace"&gt;WHILE @switch = 0&lt;br&gt;BEGIN&lt;br&gt;&lt;br&gt;    DELETE t1 FROM mytable t1&lt;br&gt;    JOIN (&lt;br&gt;        --This inner query returns duplicate rows, with the number of duplicates&lt;br&gt;        SELECT Col1,Col2,Col3, COUNT(*) AS counter&lt;br&gt;        FROM mytable&lt;br&gt;        GROUP BY  Col1,Col2,Col3&lt;br&gt;        HAVING COUNT(*) &amp;gt; 1&lt;br&gt;        ) sub&lt;br&gt;      ON t1.Col1 = sub.Col1&lt;br&gt;      AND t1.Col2 = sub.Col2&lt;br&gt;      AND t1.Col3 = sub.Col3&lt;br&gt;    WHERE t1.Value = 0  --optional where clause to choose a particular row to delete if you have a preference&lt;/font&gt;
&lt;p&gt;&lt;font face="Courier New, Courier, Monospace"&gt;    IF @@ROWCOUNT &amp;lt; 1 --no more duplicate rows&lt;br&gt;        SELECT @switch = 1&lt;br&gt;END&lt;/font&gt;
&lt;p&gt;&lt;font face="Courier New, Courier, Monospace"&gt;SET rowcount 0  --removes the 1 row limitation.&lt;/font&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-341918060925026325&amp;page=RSS%3a+Delete+duplicate+SQL+rows&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=briankramp.spaces.live.com&amp;amp;GT1=briankramp"&gt;</description><comments>http://briankramp.spaces.live.com/Blog/cns!FB414355CC45FFEB!266.entry#comment</comments><guid isPermaLink="true">http://briankramp.spaces.live.com/Blog/cns!FB414355CC45FFEB!266.entry</guid><pubDate>Fri, 20 May 2005 20:09:46 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://briankramp.spaces.live.com/blog/cns!FB414355CC45FFEB!266/comments/feed.rss</wfw:commentRss><wfw:comment>http://briankramp.spaces.live.com/Blog/cns!FB414355CC45FFEB!266.entry#comment</wfw:comment><dcterms:modified>2005-07-08T22:50:00Z</dcterms:modified></item></channel></rss>