How to store the result set in temp table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsrinivasan
    New Member
    • Mar 2007
    • 221

    How to store the result set in temp table

    Hi all,

    When i run below statement, i get some result set. But i want to store the results sets in some temp table. How can i store it?

    Code:
    DBCC SHOWCONTIG ('table_name') WITH TABLERESULTS
    Thanks,
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    You might need to get the info you need from one of the system tables or system views.

    -- CK

    Comment

    • rsrinivasan
      New Member
      • Mar 2007
      • 221

      #3
      Originally posted by ck9663
      You might need to get the info you need from one of the system tables or system views.

      -- CK
      So what to do for this to store this result in some temp table. I do not have any idea to implement this. please suggest some way to do this.

      Comment

      • JinxT
        New Member
        • Apr 2008
        • 9

        #4
        Hi,

        Take a look at this link :
        http://www.sqlserverce ntral.com/Forums/Topic550007-5-1.aspx

        J.

        Comment

        • ck9663
          Recognized Expert Specialist
          • Jun 2007
          • 2878

          #5
          JinxT is right, it can be done :)

          Check sample E from here

          specifically, the lines:

          Code:
          BEGIN
          -- Do the showcontig of all indexes of the table
             INSERT INTO #fraglist 
             EXEC ('DBCC SHOWCONTIG (''' + @tablename + ''') 
                WITH FAST, TABLERESULTS, ALL_INDEXES, NO_INFOMSGS')
             FETCH NEXT
                FROM tables
                INTO @tablename
          END

          -- CK

          Comment

          • rsrinivasan
            New Member
            • Mar 2007
            • 221

            #6
            Originally posted by ck9663
            JinxT is right, it can be done :)

            Check sample E from here

            specifically, the lines:

            Code:
            BEGIN
            -- Do the showcontig of all indexes of the table
               INSERT INTO #fraglist 
               EXEC ('DBCC SHOWCONTIG (''' + @tablename + ''') 
                  WITH FAST, TABLERESULTS, ALL_INDEXES, NO_INFOMSGS')
               FETCH NEXT
                  FROM tables
                  INTO @tablename
            END

            -- CK
            Thanks for it. It is working fine.

            Comment

            Working...