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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:51:09+00:00 2026-05-28T03:51:09+00:00

This is my temporary table : CREATE TABLE #tmpRecentTxns(SerialID nvarchar(50) null,TranDate datetime2 null) select

  • 0

This is my temporary table :

CREATE TABLE #tmpRecentTxns(SerialID nvarchar(50) null,TranDate datetime2 null)

select * 
from #tmpRecentTxns 
where #tmpRecentTxns.SerialID NOT IN 
         (SELECT distinct Phone 
          FROM ApplicationVariables 
          WHERE datediff(n, vardatetime, getdate()) <= 300)

Here Phone datatype is nvarchar(10) in database.

Problem : when I am going to select value it is taking too much time.

Please help me out how to remove this problem.

Thanks in advance.

  • 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-28T03:51:10+00:00Added an answer on May 28, 2026 at 3:51 am

    I don’t think the fact your Phone is of type NVARCHAR(10) is the reason for poor performance.

    First of all, you should make sure you have an index on the vardatetime column in your ApplicationVariables table (including the Phone column).

    CREATE INDEX IX_AppVar_VarDateTime
    ON dbo.ApplicationVariables(vardatetime) INCLUDE(Phone)
    

    Second, you should change the query so that this index can be used:

    SELECT distinct Phone 
          FROM ApplicationVariables 
          WHERE vardatetime >= DATEADD(MINUTE, -300, GETDATE())
    

    Also: I would recommend to use the MINUTE specifier for DATEDADD or DATEDIFF – much clearer what you’re trying to do.

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

Sidebar

Related Questions

This works UTF8 create temporary table test (x char(1) not null) charset=utf8; insert into
If i have this table on dataBase.js file: client.query( 'CREATE TEMPORARY TABLE IF NOT
I am creating a temp table with a query like this: CREATE TEMPORARY TABLE
My call sequence to MySQL is like this: Connection1: create temporary table 'temp_table'... Connection2:
I have a emp table, CREATE TABLE [dbo].[Emp]( [EmpId] [int] NULL, [EmpName] [nvarchar](50) COLLATE
Ok I have a temporary MySQL table with 135,000 rows, from this temporary table
I'm using SQL Server 2008. Say I create a temporary table like this one:
i want to create a temporary table on the fly from a result set
I have a table: create table A ( KEY VARCHAR(1024) not null ); where
I have the following table: CREATE TABLE `score` ( `score_id` int(10) unsigned NOT NULL

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.