Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

create a new table from view

Posted on 2014-01-11
3
327 Views
Last Modified: 2014-01-12
Hi Experts
i am trying to copy the content of the view to a new table

i am using this query

CREATE TABLE temp_Courses
  AS (SELECT distinct(Description) FROM [Training].[dbo].[masCourse]);

Open in new window


and i am getting this error
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'AS'.

i even tried this
  SELECT Description
INTO temp_courses
FROM (SELECT distinct Description FROM [Training].[dbo].[masCourse])

Open in new window


also not working i am getting this error
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ')'.

Open in new window


can you help me please
0
Comment
Question by:AZZA-KHAMEES
3 Comments
 
LVL 21

Assisted Solution

by:Dale Burrell
Dale Burrell earned 250 total points
ID: 39774364
I don't think you can create a table and insert into it at the same time - unless its a recent feature I haven't used.

The following should work to create you a temp table with the results in it:

SELECT distinct(Description)
INTO #temp_courses
FROM [Training].[dbo].[masCourse]

Open in new window

0
 
LVL 40

Accepted Solution

by:
Sharath earned 250 total points
ID: 39774370
If you already have the table, try this.
INSERT temp_Courses
SELECT distinct Description FROM [Training].[dbo].[masCourse];

Open in new window

If you don't have the table, you can try SELECT INTO and create new table
 SELECT distinct Description
   INTO temp_courses
   FROM FROM [Training].[dbo].[masCourse]

Open in new window

0
 

Author Closing Comment

by:AZZA-KHAMEES
ID: 39774379
thanks
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

860 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