Find Related Items Help

I have two tables: (condensed version of Subject) Subject and MessageSubject
CREATE TABLE [dbo].[Subject](
[SubjectID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nchar](80) NULL,
[Active] [bit] NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[MessageSubject](
[MessageSubjectID] [int] IDENTITY(1,1) NOT NULL,
[MessageID] [int] NOT NULL,
[SubjectID] [int] NOT NULL
) ON [PRIMARY]
Not shown is the table 'Message' but every message has one or more subjects (MessageSubject entries)
What I need to do is find all the subjects that were posted to a message 'with' a a given subject, not including the given SubjectID.
My guess is a #temp table or CTE or something is the way to do it, but I can't seem to find out how to do in SQL:
The procedure below is the format I need it to be (if possible) but here is what I am doing in C# code now:
I currently find all the messages for a given subject:
Then I have to query all the MessageSubject (subjects) for each message;
IF any subjects were found for a message other than the source SubjectID (related subjects) I check my list of subjects and if the index of the new related subject is not found I add it to the list.
This means I am performing ('x' + 1) number of queries for each Subject where 'x' = the number of messages and 1 query to find all the messages for the subject.
I know there has to be a way to find to find the 'Related Subject', but I can't seem to get my head around it.
Any help is appreciated, thanks.
Create PROCEDURE [dbo].[Subject_FindRelatedSubjects]
-- SubjectID Parametere
@SubjectID int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON
-- Begin Select Statement
Select [Active],[Name],[SubjectID]
-- From tableName
From [Subject] s Inner Join [MessageSubject] ms on s.SubjectID = ms.SubjectID
-- Find Subjects That Were Posted 'With' the SubjectID given
Where ...
END

Create PROCEDURE [dbo].[Subject_FindRelatedSubjects]
    -- SubjectID Parametere
    @SubjectID int
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON
    -- CTE For All Messages For This SubjectID
    ;WITH cteMessages AS
        -- Select All MessageIDs for the given SubjectID
 Select MessageID From MessageSubject ms Where ms.SubjectID = @SubjectID
    ), cteMessageSubjects As
        -- Select Only The SubjectID From CTE Messages
        Select SubjectID From MessageSubject ms2
        -- Only return iems from MessageSubject table where the SubjecteID is not equal to  @SubjectID Where ms2.SubjectID != @SubjectID
        -- And The MessageID In cteMessages
        And ms2.MessageID In (Select MessageID From cteMessages)
 -- Select Fields
 Select [Active],[Name][SubjectID]
 -- From Table Name
 From Subject
 -- Only Return Subjects In cteSubjects
 Where SubjectID in (Select SubjectID From cteSubjects)
END

Similar Messages

  • "Find Related Items" in Entourage (like Outlook on PC)?

    Hi,
    I use Outlook on a Win XP machine at work and Entourage on my Mac at home. I cannot find anywhere in Entourage where there is a command that behaves the same as the "find related items" command does in Outlook. I use this extensively on my work computer because it automatically finds any messages in my inbox and sent items which belong to the same thread and allows me to quickly select all those
    messages and file them in another folder together.
    There is a "Find Related Items" command in my Edit menu in Entourage but it is always greyed out. From what I can read about it, it will only find "related" items which I have manually created links to. Not very helpful in my opinion. Is there a third party script or something which gives Entourage the same functionality as Outlook?

    If you don't get an answer here, there is a help
    newsgroup devoted to Entourage:
    I tried there first and have gotten no replies. I saw that others were asking Entourage questions in this forum so thought I'd give it a shot. Any solutions I get from either forum I will make sure to post to the other forum.
    http://groups.google.com/group/microsoft.public.mac.office.entourage/browse_thre ad/thread/0e89f4e88b5ac1a6/#
    Thanks,
    Larry

  • Finding deleted items, help!!!!

    My computer is old and doesnt store much space, last night i downloaded an hd show on itunes that was 1.34 gig., for my com this is a big hunk of space. So i tried to sync it to my ipod and because i have a classic it didnt work, anyway so i figured why keep it, so i unchecked it and hit delete. unfortunately no option came up about moving it to the recycle bin, it just deleted it from my library. Any ideas where i could find this deleted item? thanks

    See if this helps: iTunes Music Store: Finding missing music and video downloads

  • Where can I find detailed, systematic HELP for advanced topics relating to Thunderbird?

    In moving from XP to Windows 7, I opted for Thunderbird as email client in order to bypass Microsoft's hyper-intrusive Windows Live Mail (I used Outlook Express for years).
    I have a very complicated email structure, and it's taken me weeks (seriously) to learn how to replicate it in TBird. Now I'm trying to customize TBird further, but none of the TBird articles/forum Q&A's/Google searches address my questions.
    There is no live tech support for TBird, and I'm just about ready to leave it for good. However -- one last effort: where can I find detailed, systematic HELP for advanced topics relating to Thunderbird?
    Thanks.

    I am no expert, but I don't know of any authoritative reference as to what elements of HTML and CSS are supported in Thunderbird. However, as I believe you appreciate, it's more than just what Thunderbird supports, but one must also think about what is likely to work in other email clients. Keep it simple. Avoid ancient deprecated tags that other email clients may not support, and for similar reasons, avoid cutting edge technology. Remember that recipients using tablets or smartphones won't appreciate large fancy email documents.
    The only thing ''guaranteed'' to work in email is plain text. ;-)
    If you haven't already discovered it, the Stationery add-on is designed specifically to support OE stationery in Thunderbird. Your existing stationery may "just work" in this add-on. It makes switching between various stationery templates much easier, but I'm not confident that it will affect interpretation of your CSS or HTML coding.
    Your code is at least clean and minimal. Most times my involvement with troublesome templates and signatures centres on the horrible bloat and mso custom code generated by Word or Outlook.
    Having said that, you and I are mortal enemies, as I don't have much patience with what you aspire to achieve. I specifically don't like background images, nor being obliged to suffer other folks' bizarre choice of typefaces and colours (but your simple 12pt black Tahoma is quite inoffensive. ;-) ) I'm of an age where my tolerance and eyesight are easily offended.
    Nonetheless, I'm intrigued by how to parse the tag for the background image, as it doesn't look like a legitimate pathname to a graphics file. Does the background image actually appear as required?

  • Not able to find the related datasources ,, help..

    Hi Experts ,
    BI with CRM
    I am trying to find the relavent Datasources for the below mentioned Tables in CRM ,,plz help to find out the relavent Datasources ,,,I tried in all forms ,but not able to find ,, need your help.
    Thanks in advance
    Table ::
    CRMD_MKTATTR_SET----->>> Datasource???
    COMD_PAYPLAN_DC----->>> Datasource???
    COMD_PAYPLAN_D------->>> Datasource???
    TB033----
    >>> Datasource???
    ZUCORDSET----
    >>>>>Datasource???
    Regards
    Ramana

    package com.elevenworks.swing.treetable;
    //Here i dont have this dependency code
    //So i want a jar file for that
    import org.jdesktop.swingx.JXTreeTable;
    import javax.swing.*;
    import javax.swing.tree.TreeCellRenderer;
    import java.awt.*;
    public class BrushedMetalTreeCellRenderer implements TreeCellRenderer
         protected JLabel label;
         public BrushedMetalTreeCellRenderer()
              label = new JLabel();
         public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
              label.setForeground(Color.BLACK);
              if (selected)
                   Component vRenderPane = tree.getParent();
                   if (vRenderPane != null)
                        JXTreeTable vTable = (JXTreeTable)vRenderPane.getParent();
                        if (vTable != null)
                             if (vTable.hasFocus())
                                  label.setForeground(Color.WHITE);
              label.setText(value.toString());
              return label;
    }

  • Related Item link is broken in DispForm.aspx for a task in Workflow Tasks list if file name contains " ' " (single quote)

    Description:
    We have created a custom workflow in Microsoft Visual Studio 2013 and SharePoint 2013. This Workflow is associated with a Document library.
    This Workflow starts as soon as any new item is created OR updated in Document library and creates a Task in Workflow Tasks list.
     Related Item link is not working in following scenario -
    Upload a file that contains “ ' “
    in its name, in a document library
    Navigate to Workflow Tasks list
    Open View Item form (DispForm.aspx ) of  Task Created by workflow then click on link in Related Item fields
    OUPUT:
    Related Item link  truncates after “ ' “
    Eg.
    Original Link: http://<Site URL>/Documents/te'st.txt
    Related Item Field: http://<Site URL>/Documents/te
    Is this known bug in SharePoint 2013 OR any hotfix available to fix it.

    Hi,
    As I tested per your description, I can reproduce the issue as well.
    From what I have found out, it seems SharePoint resolve single quote into different code in different place. During the test, if I set Task Name to Document Name, single quote will be resolved to &#39; , if I set some field to Document encoded URL, single
    quote will be resolved to %27 . For now, I haven't found out any article talking about this issue.
    As workaround, we may find out a way to change the Related Item field. However, it is OOB field in workflow task (SharePoint 2013) content type, and this content type cannot be modified in form.
    I'd suggest you add new column to get document url and place in the form in Task content type settings.
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • SCSM 2012 Forms (related items tab)

    Hi,
    We are using SCSM in our Production environment. I have a question about the "Select Object" function on Related Items Tab. When we  click on Add button on Related Items Tab under (lets say) "Configuration Items: Computer, Services and
    People" section, it opens a "Select Objects" dialog box with a list of option. Some of these options are not useful to us as we are not using them or may not plan to use in future. For example under the "Select Objects" dialog
    box  the‘object type’ list contains Database twice (as well as another option as Databases) which makes it difficult to search for the appropriate Database CI. Is there a way the "non used" option can be removed from this drop down list?
    Please advise. Any help will be appreciated.
    Thanks

    You would have to write your own dialog box. It is called a LaunchAddInstancePickerDialog (found in Microsoft.EnterpriseManagement.ServiceManager.Application.dll). You can tell it to provide a list based on a type (ex. Config Item) and a selected class (ex.
    computers). And that is just one of the overloads.
    You would then have to replace the button which triggers the dialog. Also not too difficult. I think
    this post by Rob Ford is actually the best reference (I can find as of now).
    If you haven't coded before this is massive undertaking. I you have, then it is advantageous to have C# experience. And still you should expect hours of Work to wrap your head around this.
    http://codebeaver.blogspot.dk/

  • Error when deleting file: Could not find this item. This is no longer located in ...

    We are setting up a new Windows 2012 server. Users access this server using a 'terminal services'. We have mapped some folders from a legacy server (different domain). Using group policy preferences, we map this folder as a drive for a user.
    When user wants to delete some files, he get's the error: 'Could not find this item ..' The error is displayed to the user and it looks like the file can't be deleted. But when I press the F5 (refresh) button, the file is gone. My problem is very similar
    to a problem in the following post: http://social.technet.microsoft.com/Forums/windowsserver/en-US/042e747a-0e25-4190-b0a2-82f3e9635eb0/can-not-delete-file-error-is-could-not-find-this-item?forum=w7itprogeneral
    When I create 'txt' (or 'pdf', 'zip') file, i can delete it without the error. When I create 'xlsx', 'docx', 'pptx', 'bmp', 'jpg', I get the error.
    Does somebody have an idea, how can I fix the cause of this problem? (I can't tell to users to hit the F5 button everytime when they face this issue)
    Thank you for your help in advance!
    Juraj

    Hi,
    Please check if the problematic files’ filename ended with a dot. If so, you could refer to the article below to troubleshoot the issue:
    Solved: “Cannot read from the source file or disk”
    http://blog.dotsmart.net/2008/06/12/solved-cannot-read-from-the-source-file-or-disk/
    Regards,
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Using shortcuts in Item Help Text

    Hello everyone,
    I have a problem using shortcuts in Help Text sections of items. It says in the help "Item help supports shortcuts using "SHORTCUT_NAME" syntax." but it seems not. In the shortcuts sections of the shared components, it doesn't says that shortcuts can be used in Help text section.
    I am using 3.1. It is a 3.1 bug? I didn't see int he corrected bug's list that is was a bug in 3.1 so.
    If it is not a bug and it just doesnt work in help text sections, do you have any suggestion to supply help text from a help system somewhere else in the organisation?
    Thank, Bpprive

    Thank a lot,
    You can find the information by clicking on "Show edit link" on a page, then on the edit link of a textfield, scrolling to the section "Item help text" and finally on "help text", juste above the textarea.
    "Identifies help text for a page item. This help can be displayed by a help system. Item help supports shortcuts using "SHORTCUT_NAME" syntax."
    I was really happy to find an easy and customizable way to implement help text provided by help system. I have some more ideas, but I't was far away the greatest!
    Thank, bpprive

  • HT201210 I'm trying to update my iOS to 6.0, using iTunes (with my 4s connected via USB and WiFi is on also). I get a message that 'there are purchased items on my iPhone that have not been transferred to my iTunes library. Yet, I can't find those items!

    I'm trying to update my iOS to 6.0, using iTunes (with my 4s connected via USB and WiFi is on also). I get a message that 'there are purchased items on my iPhone that have not been transferred to my iTunes library. Yet, I can't find those items! Help!  There is not error message number just the text message. I've searched for an answer but have found nothing on "transfering items purchased to your iTunes library".

    Right click on your device icon on the left pane of iTunes and click on transfer pur....

  • How to export related items

    Hi All,
    I couldn't find any information about exporting related item list, is it possible to export related items?
    For example, how can i export Opportunity Product Revunues of an Opportunity record?

    Hi,
    One option to to create an Analytics Report on the Opportunity Product Revenues subject Area and then export from there.
    This is when you want the Related Item together with the header.
    Hope this helps

  • Since updating to 3.6.1 I don't get an empty browser window in my tool bar whe. it opens --- just a list of search engines. I can't find anything in "Help" or the FAQ's that seem to address this. My only choice seems to go back to Safari.

    Since updating to 3.6.1 I don’t get an empty browser window in my tool bar when it opens --- just a list of search engines. I can’t find anything in “Help” or the FAQ’s that seem to address this.
    My only choice seems to go back to Safari.

    I am not sure what your problem is, can you give more details.
    One possibility is you may be in full screen mode, for details on fixing that see the [[menu bar is missing]] article.
    If you are missing various toolbar items, see the [[back and forward or other toolbar items are missing]] article.
    If your problem is something else please give more details.

  • FQDN Share Access (Could not find this item)

    Say I have the domain 'contoso.com', which is resolved by a domain controller (Controller). I have a share (Share) on Controller with everyone permissions (full control, just to test).
    Now I can access Share via '\\Controller\Share' or '\\Controller.contoso.com\Share'. This is fine.
    I can also access Share via '\\contoso.com\Share'. This is not fine, as follows.
    If I try to e.g. create a new folder, I get 'Could not find this item. This is no longer located in contoso.com.'
    Why is Share listed in the shares of contoso.com if it isn't located there?

    Hi,
    Do you mean that you can access Share via '\\Controller\Share' or '\\Controller.contoso.com\Share' and create a new folder in it without issue, however, you cannot create a new folder in the Share folder when access share via '\\contoso.com\Share'?
    I have done a test on my PC, when access share via '\\contoso.com\Share' the content is empty. I create a new folder in it, then I have a same issue with you. It seems that it is a side effect of having shared folders on a domain controller.
    Domain.local shows shares but are empty
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/57d2120c-46c7-430e-9d3e-3d589a02dde2/domainlocal-shows-shares-but-are-empty?forum=winserveressentials
    Regards,
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Could not find selected item matching value "New" warning message in ADF

    Hi,
    I have a selectOneChoice1 for a field which has the following fixed values in it. And while creating it, I selected the 'SelctionRequired' option so that this field will always have a value.
    New
    Pending
    Completed.
    While navigating to this page, I am trying to set the value to 'New' (Retrieved from the DB) in the backing bean. But when the page is rendered, the above field is empty with the above options in the list and jdev has the follwing error message in its log.
    WARNING: Could not find selected item matching value "New" in CoreSelectOneChoice[UIXEditableFacesBeanImpl, id=selectOneChoice1]
    Can any one help me with this issue?
    Thanks,
    Priya

    The value of a list binding is the zero-based integer position in the list that is selected, not the actual underlying value.
    The simplest way to set the value of an attribute is to use an attribute binding (which can be bound to the same attribute as the list binding). When you set the value of an attribute binding, it sets the value as you supply it. Otherwise, you'd need to set the list binding's value to the numerical "slot" number of the one you want to change the value to.

  • Can not delete file. Error is "Could not find this item".

    I get the following error when trying to delete a file:  "Item not found".  This is a Word 2007 document that would not save properly so I saved it with a different name.  Now I can't delete the original file.
    The body of the error states "Could not find this item.  This is no longer located in... . Verify the item's location and try again.

    Hi,
    I'm having exact the same problem with a file with a long name, to delete, move, rename, attribute change, etc. I deleted the file, which I receive the confirmation. However, the file is still there, with zero bytes and no extension. When I try
    to delet, move or change the file, I get the error "Could not find this item, This is no longer located in xxx. Verify the item's location and try again."
    I tryed everything: Using DOS, there's no 8.3 name format; In safe mode; chkdsk and sfc. Nothing worked.
    I also tryed the tricks in http://www.sevenforums.com/general-discussion/27924-could-not-find-item-when-deleting-files-3.html
    http://forums.techarena.in/vista-help/1038943.htm
    Without success.
    I took some more time and found this tool on the net "DelinvFile". It works perfectly, after trying EVERYTHING!!!.
    I Have Windows 7 professional 64bits and NTFS.
    Thank you very much.
    Thankyou Thankyou Thankyou Thankyou......... We are almost bald tearing our hair out over this issue and how to fix it.     Delin File WORKS...... At the cost of about 28 bucks well worth it.............. Good onya mate............

Maybe you are looking for

  • Report Painter for New GL

    Dear experts, I need to create a custom report with ReportPainter with the data you see with t.FAGLB03. Since there are no standard reports for New GL, to copy and modify, i created a library by copying the library 0FL (Table FAGLFLEXT) and i stopped

  • Mp4 needing to be converted to flash for viewing

    Hi I have premier elements and I was hoping to be able to convert existing mp4 files to flash to use on a website.  I don't see how I can do that... any suggestions? Thanks. Debi

  • Table Styles Override

    Hi, I'm using CS4 (PC) and realised that the plus sign indicating local overrides don't show in Table and Cell styles. Is that a glitch or that's the way it's meant to be? Any takers? Tricia

  • Why can't access my application from different IP region.

    I use the default configuration in the installation process. software package is as_windows_x86_101300_disk1.zip All the servers have IP address like 10.37.71.*** after i deploy my application server, local machine can access my application and other

  • VKTM process taking longtime to start in my RAC environment

    Hi All, I'm having a 2node 11.2.0.3 RAC setup with ASM on Solaris 10 x64 platform. During the restart of the database, it is taking longtime to start around 10mins. Is there any possibility to trace this situation? Thanks,