Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8730369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:00:28+00:00 2026-06-13T09:00:28+00:00

I have 2 tables. One is called Tasks and the other one is called

  • 0

I have 2 tables. One is called “Tasks” and the other one is called “TaskDescription”
in my “Task” the setup looks like this:
“taskID(primary)”,”FileID”,”TaskTypeID” and a bunch of other columns irrelevant.

Then in my “TaskDescription”, the setup looks like:
“TaskTypeID”, “TaskTypeDesc”

so for example if TaskTypeID is 1 , then the description would be”admin”
or if TaskTypeID is 2, then TaskTypeDesc would be “Employee” etc.

The two tables have a relationship on the primary/foreign key “TaskTypeID”.

What I am trying to do is get a task id, and the TaskDesc where the FileID matches the @fileID(which I pass in as a param). However in my query I get multiple rows returned instead of a single row when trying to obtain the description.

this is my query:

SELECT taskid,
       ( 'Task ID: '
         + Cast(cf.taskid AS NVARCHAR(15)) + ' - '
         + Cast((SELECT DISTINCT td.tasktypedesc FROM casefiletaskdescriptions
         td JOIN
         casefiletasks cft ON td.tasktypeid=cft.tasktypeid WHERE cft.taskid =
         1841 )AS
         NVARCHAR(100))
         + ' - Investigator : ' + ( Cast(i.fname AS NVARCHAR(20)) + ' '
                                    + Cast(i.lname AS NVARCHAR(20)) ) ) AS
       'Display'
FROM   casefiletasks [cf]
       JOIN investigators i
         ON CF.taskasgnto = i.investigatorid
WHERE  cf.fileid = 2011630988
       AND cf.concluded = 0
       AND cf.progressflag != 'Conclude' 

I am trying to get the output to look like “Task ID: 1234 – Admin – Investigator : John Doe”. However I am having trouble on this part:

CAST((select DISTINCT td.TaskTypeDesc from CaseFileTaskDescriptions td 
JOIN CaseFileTasks cft ON td.TaskTypeID=cft.TaskTypeID 
where cft.TaskID =1841 )as nvarchar(100))

This seems to work but the problem is I have to hard code the value “1841” to make it work. Is there a way to assign a “taskID” variable with the values being returned from the TaskID select query, or will it not work since I think sql runs everything at once instead of line by line.

EDIT-this is in Microsoft SQL Server Management Studio 2008

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:00:30+00:00Added an answer on June 13, 2026 at 9:00 am

    You can dynamically reference a column that exists in your FROM set. In this case, it would be any column from casefiletasks or investigators. You would replace 1841 with the table.column reference.

    Update

    Replacing your static integer with the column reference, your query would look like:

    SELECT taskid,
           ( 'Task ID: '
             + Cast(cf.taskid AS NVARCHAR(15)) + ' - '
             + Cast((SELECT DISTINCT td.tasktypedesc FROM casefiletaskdescriptions
             td JOIN
             casefiletasks cft ON td.tasktypeid=cft.tasktypeid WHERE cft.taskid =
             cf.taskid )AS
             NVARCHAR(100))
             + ' - Investigator : ' + ( Cast(i.fname AS NVARCHAR(20)) + ' '
                                        + Cast(i.lname AS NVARCHAR(20)) ) ) AS
           'Display'
    FROM   casefiletasks [cf]
           JOIN investigators i
             ON CF.taskasgnto = i.investigatorid
    WHERE  cf.fileid = 2011630988
           AND cf.concluded = 0
           AND cf.progressflag != 'Conclude' 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, one called pinned and one called unread pinned looks like
I have two tables one called fs_note the other called dumy_fs_note I created after
So i'm having this problem. I have two tables (Oracle), one is called Destination
I have two tables one called details and the other called c_details. Both tables
I have two tables, one called calendars and the other one called events .
I have two tables one called Point and other called Poly i have around
I have a couple of tables in my database, one called Task , and
i have two tables one is called addons and holds information about different addons,
I have two tables, one called cart and one called items. Now I want
I have some tables. These tables all have one column in common called 'classified_id':

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.