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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:32+00:00 2026-05-22T20:51:32+00:00

I have a table [MyTable] with a column [MyColumn] NVarchar(50). I have a nonclustered

  • 0

I have a table [MyTable] with a column [MyColumn] NVarchar(50). I have a nonclustered index on this column, now while running the below two queries:

SELECT  1
FROM    [MyTable] M
WHERE   M.[MyColumn] = @MyColumn

SELECT  1
FROM    [MyTable] M
WHERE   M.[MyColumn] = COALESCE(@MyColumn, M.[MyColumn] )   

I noticed the first query is using Index Seek (NonClustered) and the second one is using Index Scan (Non Clustered). May I know how will I make use of index seek with coalesce or isnull ?

  • 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-22T20:51:33+00:00Added an answer on May 22, 2026 at 8:51 pm

    May I know how will I make use of
    index seek with coalesce or isnull ?

    Perhaps not an answer to your question but you can have two different queries. One for the case where @MyColumn is null and one for the case where you want to use @MyColumn in the where clause.

    IF @MyColumn IS NULL
    BEGIN
      SELECT  1
      FROM    [MyTable] M
    END  
    ELSE
    BEGIN
      SELECT  1
      FROM    [MyTable] M
      WHERE   M.[MyColumn] = @MyColumn
    END  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this XML in a column in my table: <keywords> <keyword name=First Name
I have a composite index on three column in one of my table. It
I have created a table called myTable with a column called CURRENT_DATE and it's
In MSSQL I have a table created like this: CREATE TABLE [mytable] (fkid int
I have table mytable where value of column myValue is null. I have application
I am using oracle 10g EE database.I have one table mytable and has two
I have a table as below; <table id=mytable> <tr> <td>cola1</td> <td>cola2</td> <td>cola3</td> <td class=rem>cola4</td>
let's say I have a column on my table defined the following: MyColumn smallint
I have a table that includes the following column: mytable <- data.frame(beta_0 = c(1,2,3)
In Oracle, I have a table called MyTable. This table has columns 'A' and

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.