Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. create temporary table from select

create temporary table from select

Scheduled Pinned Locked Moved Database
databasesql-serversysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gottimukkala
    wrote on last edited by
    #1

    Hi all, I need to create a temporary table for the results of my select statement in sql server 2005. Here is my SQL statement which does the select : SELECT DISTINCT IM.MENU_ID AS 'StructureId', IM.MENUITEM_ID AS 'CategoryId', EA.Title AS 'Name' FROM HN_IM_JOIN IM INNER JOIN HNIM_ElementAttributes EA ON EA.OwnerId = IM.MENUITEM_ID INNER JOIN HNIM_Element EL ON EL.ID = IM.MENUITEM_ID WHERE EA.Lcid = 'en' AND IM.MENU_ID = 'bd966aba' ORDER BY EA.Title but I want to write these to a temporary table. Any Idea please

    A 1 Reply Last reply
    0
    • G gottimukkala

      Hi all, I need to create a temporary table for the results of my select statement in sql server 2005. Here is my SQL statement which does the select : SELECT DISTINCT IM.MENU_ID AS 'StructureId', IM.MENUITEM_ID AS 'CategoryId', EA.Title AS 'Name' FROM HN_IM_JOIN IM INNER JOIN HNIM_ElementAttributes EA ON EA.OwnerId = IM.MENUITEM_ID INNER JOIN HNIM_Element EL ON EL.ID = IM.MENUITEM_ID WHERE EA.Lcid = 'en' AND IM.MENU_ID = 'bd966aba' ORDER BY EA.Title but I want to write these to a temporary table. Any Idea please

      A Offline
      A Offline
      andyharman
      wrote on last edited by
      #2

      Try:

      SELECT DISTINCT IM.MENU_ID AS 'StructureId', 
          IM.MENUITEM_ID AS 'CategoryId', EA.Title AS 'Name' 
        INTO #temp1
        FROM HN_IM_JOIN IM
        INNER JOIN HNIM_ElementAttributes EA 
          ON EA.OwnerId = IM.MENUITEM_ID
        INNER JOIN HNIM_Element EL
          ON EL.ID = IM.MENUITEM_ID
        WHERE EA.Lcid = 'en' 
        AND IM.MENU_ID = 'bd966aba'
        ORDER BY EA.Title
      

      Regards Andy

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups