What are "Auxiliary Tables" in SQL Server ?

Posted on 2010-01-07
Last Modified: 2012-05-08

What are "Auxiliary Tables" in SQL Server ? Can you please provide a simple example on it ? Please explain the code in simple terms so that i can better understand it easily. Please do not provide articles.

Question by:milani_lucie
    LVL 60

    Expert Comment

    Ive not heard of an auxiallary sql server table before...are you referring to the system tables?

    select * from sys.tables
    select * from sys.procedures


    select * from sys.dm_exec_requests
    LVL 75

    Assisted Solution

    by:Aneesh Retnakaran
    LVL 18

    Accepted Solution

    Auxiliary tables are a kind of helper tables. Samples: auxiliary table of numbers and auxiliary number of dates. These tables are usually used for some optimizations. They often allow to perform set based operations instead of cursors or loops.

    Here you can find some old fashioned scenarios when an auxiliary table is useful:

    It's fairly easy to create an auxiliary table with Common Table Expression mechanism in SQL Server 2005/2008:

    DECLARE @MaxNumber int;
    SET @MaxNumber = 1000000;
    ;WITH CTE_Nums AS (
      SELECT 1 Num
      SELECT Num + 1
      FROM CTE_Nums
      WHERE Num < @MaxNumber
    SELECT Num
    INTO dbo.AuxiliaryTableOfNumbers

    Now all you have to do is to put an index on this table (you can simply add a primary key on Num column) and the table is ready for use.

    Author Comment


    I do not have access to that site. Can you please provide me the code and explain it little bit ?

    LVL 59

    Expert Comment

    by:Kevin Cross
    Yes, it greatly depends on your definition of auxiliary tables.  As Tim pointed out, you could be referring to system tables.  Additionally, you could think of this as utility (helper) tables such as a numbers table.

    Here is another look at Numbers table example with thought on having a utility / helper / auxiliary database dedicated to such tables.

    So please define what you were looking for with "auxiliary".
    LVL 59

    Expert Comment

    by:Kevin Cross
    BTW, the link from Aneesh is to an article that is referring to auxiliary tables as helper tables that aid you in making your T-SQL solutions easier/more elegant; therefore, it falls in line with brejk's comment.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now