create temporary table from select
-
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
-
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
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