﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Help Needed please / 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>Wed, 19 Jun 2013 11:39:46 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Help Needed please</title><link>http://www.sqlservercentral.com/Forums/Topic1395396-392-1.aspx</link><description>I like to advise people to avoid self-JOINs whenever possible because I've always found them to be performance dogs across large row sets.  Woof!Not sure this is faster than the EXISTS or IN solutions proposed earlier, but it will almost certainly be swifter than a self JOIN.[code="sql"]DECLARE @T TABLE (ProductID VARCHAR(50))INSERT INTO @TSELECT '003223' UNION ALL SELECT '003225' UNION ALL SELECT '003227'UNION ALL SELECT '003227A' UNION ALL SELECT '003236' UNION ALL SELECT '003236A'UNION ALL SELECT '003241' UNION ALL SELECT '003273' UNION ALL SELECT '003273A'SELECT ProductIDFROM (    SELECT ProductID, m=MAX(n) OVER (PARTITION BY LEFT(ProductID, 6))    FROM (        SELECT ProductID            ,n=ROW_NUMBER() OVER (PARTITION BY LEFT(ProductID, 6) ORDER BY (SELECT NULL))        FROM @T) a) bWHERE m &amp;gt; 1[/code]Anyway, that is another alternative you can consider.</description><pubDate>Wed, 12 Dec 2012 17:47:38 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Help Needed please</title><link>http://www.sqlservercentral.com/Forums/Topic1395396-392-1.aspx</link><description>Thanks for your help everyone. Did some further work last night and came up with a solution for my needs.SELECT a.ur_number, b.ur_number, c.name_last, c.name_firstFROM SYS_CLI_Client aINNER JOIN SYS_CLI_Client b ON (SUBSTRING(a.ur_number, 1, LEN(a.ur_number) - 1)=b.ur_number)INNER JOIN SYS_GEN_Person c on (b.person_id = c.id)  WHERE a.ur_number LIKE ('%[A-Z]')</description><pubDate>Wed, 12 Dec 2012 14:50:44 GMT</pubDate><dc:creator>terryphone</dc:creator></item><item><title>RE: Help Needed please</title><link>http://www.sqlservercentral.com/Forums/Topic1395396-392-1.aspx</link><description>Like wise, assuming you are looking at the first 6 characters.SELECT ID FROM (SELECT SUBSTRING(ID,1,6) ID,COUNT(1)x  FROM #TGROUP BY  SUBSTRING(ID,1,6))D WHERE D.x&amp;gt;1</description><pubDate>Tue, 11 Dec 2012 21:42:26 GMT</pubDate><dc:creator>peacesells</dc:creator></item><item><title>RE: Help Needed please</title><link>http://www.sqlservercentral.com/Forums/Topic1395396-392-1.aspx</link><description>Sorry - I forgot the crucial "AND t2.ID &amp;lt;&amp;gt; t1.ID".  I've corrected my original post.</description><pubDate>Tue, 11 Dec 2012 20:49:19 GMT</pubDate><dc:creator>doug.baker-706021</dc:creator></item><item><title>RE: Help Needed please</title><link>http://www.sqlservercentral.com/Forums/Topic1395396-392-1.aspx</link><description>Hey Terry unless I understood wrong I am not sure that Dougs solution actually does what you want. Sorry Doug, not sure you tested your code or perhaps you mistyped something.The code I gave gives 6  rows, Doug yours gave 9.NOTE: I'm new to this so when I posted my T-SQL it still converted the &amp;gt; (greater than sign) to the escaped characters, ah well .</description><pubDate>Tue, 11 Dec 2012 20:37:24 GMT</pubDate><dc:creator>ShineBoy</dc:creator></item><item><title>RE: Help Needed please</title><link>http://www.sqlservercentral.com/Forums/Topic1395396-392-1.aspx</link><description>Thanks Doug, But it does not seem to be filtering out the id's that are single entries.</description><pubDate>Tue, 11 Dec 2012 20:36:10 GMT</pubDate><dc:creator>terryphone</dc:creator></item><item><title>RE: Help Needed please</title><link>http://www.sqlservercentral.com/Forums/Topic1395396-392-1.aspx</link><description>Hi terryphone,If the data is reliably as you listed (the data is alphanumeric and the "like" IDs are always 6 numeric digits with or without a letter appended), you should be able to get your list from the following query:[code="sql"]SELECT ID                              --I'm assuming the column name is ID, substitute the true column nameFROM TableName t1                      --I'm giving your table this generic table name, substitute the true table nameWHERE EXISTS (  SELECT *  FROM TableName t2                    --substitute the true table name here as well  WHERE LEFT(t2.ID,6) = LEFT(t1.ID,6)  --substitute the true column name here as well    AND t2.ID &amp;lt;&amp;gt; t1.ID  )ORDER BY ID[/code]Hope that helps.--Doug</description><pubDate>Tue, 11 Dec 2012 20:24:53 GMT</pubDate><dc:creator>doug.baker-706021</dc:creator></item><item><title>RE: Help Needed please</title><link>http://www.sqlservercentral.com/Forums/Topic1395396-392-1.aspx</link><description>Assumed that field name is ID and that it is the first 6 characters is the portion you are looking atI loaded it all into a temp table and used:[code="sql"]Select ID from #Temp where Left(id,6) IN (Select left(id,6) from #Temp group by left(id,6) having count(*) &amp;gt; 1)[/code]</description><pubDate>Tue, 11 Dec 2012 20:23:02 GMT</pubDate><dc:creator>ShineBoy</dc:creator></item><item><title>Help Needed please</title><link>http://www.sqlservercentral.com/Forums/Topic1395396-392-1.aspx</link><description>Hi. I have a table with figures below.003223003225003227003227A003236003236A003241003273003273AI need to do a search to find all items where the id is like other id's and exclude all others.So i need to list 003227003227A003236003236A003273003273A</description><pubDate>Tue, 11 Dec 2012 19:46:12 GMT</pubDate><dc:creator>terryphone</dc:creator></item></channel></rss>