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 648403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:49:43+00:00 2026-05-13T21:49:43+00:00

I have a table with the following columns: EntityId, EntityName, EntityProfile, …………….. I want

  • 0

I have a table with the following columns:
EntityId, EntityName, EntityProfile, ……………..

I want to select the Id and Name and true/false column based on the value of entity profile,
for example a returned result set like below, would mean that entities 1&2 have profiles while 3 not.

1 Name1 True
2 Name2 True
3 Name3 False
etc.....

I know I can do it using a function that return true/false based on the profile value like this:
SELECT EntityId, EntityName, dbo.EntityHasProfile(EntityId) AS HasProfile FROM Entities

but I’m returning a large no. of records and with this function call for each record, the query is very slow, and when I remove the function call the query execution time drops significantly.

So is there another way of doing this?
Thanks

  • 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-05-13T21:49:43+00:00Added an answer on May 13, 2026 at 9:49 pm

    Use a CASE. I would post the specific code, but need more information than is supplied in the post – such as the data type of EntityProfile and what is usually stored in it. Something like:

    CASE WHEN EntityProfile IS NULL THEN 'False' ELSE 'True' END
    

    Edit – the entire SELECT statement, as per the info in the comments:

    SELECT EntityID, EntityName, 
           CASE WHEN EntityProfile IS NULL THEN 'False' ELSE 'True' END AS HasProfile
    FROM Entity
    

    No LEFT JOIN necessary in this case…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: SELECT <column>, count(*) FROM <table> GROUP BY <column> HAVING
I have a table with the following columns: A B C --------- 1 10
I have a pictures table that has the following columns: PICTURE_ID int IDENTITY(1000,1) NOT
I have the following code, I'm trying to get a table with 4 columns
I have the following query: select column_name, count(column_name) from table group by column_name having
I have a table with following columns and data FldID | Rev | Words
I'm using SQL-Server 2005 Standard. I have Users table with following columns: userID(int), userImage(varchar),
I have a table with the following columns: SignatureID PatientID PatientVisitID TreatAuthDate HIPAADate DrugTestDate
I have a table with the following columns in table: id, t1, t2, t3,
I have a table with the following columns and data: activity_dt | activity_amt 2009-01-01

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.