none
Run 2 queries at the same time.

    Question

  • I have two queries

    For example

    query1: select * from table1

    query2: select * from table2

    what I want both the queries run at the same time in the query analyzer. Please  guide me how to do that


    Smash126

    Tuesday, October 22, 2013 11:27 AM

Answers

All replies

  • Open two windows and run the  queries.

    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence

    Tuesday, October 22, 2013 11:34 AM
    Answerer
  • what I want both the queries run at the same time in the query analyzer.


    Then you have to open a second query editor (= second session) and run each query in a separate query editor.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Tuesday, October 22, 2013 11:34 AM
  • can we run in the same query editor

    Smash126

    Tuesday, October 22, 2013 11:37 AM
  • can we run in the same query editor

    In the same query editor = same SQL Server session, the two queries will run sequentially.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Tuesday, October 22, 2013 11:38 AM
  • You meant to say  if I enter these two  in the query analyzer and run like this. They will run at the same time

    SELECT DISTINCT  (FISCALYEAR-1)*100+FISCALMONTH PERIODID
    FROM
    DIM_FISCAL_CALENDAR
    WHERE DATE_ID =CAST(GETDATE() AS DATE)

    SELECT
    DISTINCT
    FISCALYEAR,
    FISCALMONTH,
    FISCALYEAR*100+FISCALMONTH PERIODID,
    CAST(FISCALYEAR AS VARCHAR(40))+'-'+CASE WHEN LEN(CAST(FISCALMONTH AS VARCHAR(2)))=1 THEN '0'+CAST(FISCALMONTH AS VARCHAR(2)) ELSE CAST(FISCALMONTH AS VARCHAR(2)) END PERIODDESC
    FROM
    DIM_FISCAL_CALENDAR
    WHERE FISCALYEAR>=2004 AND DATE_ID<=CAST(GETDATE() AS DATE)
    ORDER BY
    FISCALYEAR DESC,
    FISCALMONTH DESC


    Smash126

    Tuesday, October 22, 2013 11:41 AM
  • You meant to say  if I enter these two  in the query analyzer and run like this. They will run at the same time


    No, they will be executed in one batch, but the queries run sequentially, first the first query and then the second.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Tuesday, October 22, 2013 11:49 AM
  • use waitfor time

    tested in my local .more info at

    http://technet.microsoft.com/en-us/library/aa260678%28v=sql.80%29.aspx

    BEGIN
       WAITFOR TIME '12:52'
       select getdate()
    END


    Ramesh Babu Vavilla MCTS,MSBI

    Tuesday, October 22, 2013 11:53 AM