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

  • Home
  • SEARCH
  • 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 6808307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:56:22+00:00 2026-05-26T19:56:22+00:00

I am using SQL Server 2008. I have a Non-Unique Non-clustered index on a

  • 0

I am using SQL Server 2008. I have a Non-Unique Non-clustered index on a DateTime Column “DateFrom”. I am searching the table based on this column. I just wanted to know the affect of CONVERT() function on INDEX see below:

Query1:
SELECT  *
FROM    myTable
WHERE   CONVERT(VARCHAR(10),DateFrom,23) >= '2011-01-01'

Query2:
SELECT  *
FROM    myTable
WHERE   DateFrom >= '2011-01-01 00:00:00.000'

I have checked & found no difference. But i was thinking that since the column is CONVERTED, so the index may not be used by the SQL Server, is it correct?

Please forgive me, if this is not a proper question.

  • 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-26T19:56:22+00:00Added an answer on May 26, 2026 at 7:56 pm

    Generally, when you have a function on the left side of the comparison in a WHERE clause, the server will be unable to utilize the index on the referenced column.

    In your first example, there is no comparison to the DateFrom column directly. Instead, you are using a function on the column. When the server expands this, it must perform the function on each column value, and the resulting value is not indexed. Therefore, no index can be used to improve the query.

    Also, in your first example, you indicated that the DateFrom column is a datetime column. Yet, you’re converting the column to a string and doing a string comparison. Hence, the server will not use your datetime index.

    In your second example, you are comparing the constant value with the date column directly, so the server may utilize the index. The server will convert the string constant on the right side of the comparison into a datetime value. However, it won’t use the index in all cases. For example, if you have a very few number of rows, the server may decide not to use the index and just scan the few rows.

    Both queries may yield the same result set, but they are still very different.

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

Sidebar

Related Questions

I'm using SQL Server 2008 R2 and have a simple table with a column
I'm using SQL Server 2008 and I have a table with three columns: Length
I am using T/SQL in Microsoft SQL Server 2008 I have a table CREATE
I am using SQL Server 2008 R2 and I want to add a non-clustered
Using SQL Server 2008, I have abc and xyz table abc abc_id | xyz_id1
I am using SQL Server 2008 Management Studio and have a table I want
I am using SQL Server 2008 R2 and I have an INT column where
I am using SQL Server 2008. I have a table like below: ID Name
I am using SQL Server 2008 . I have a table with the following
I'm using SQL Server 2008. I have a NVARCHAR(MAX) column called Title and i

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.