Solved

create a new table from view

Posted on 2014-01-11
3
328 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
[X]
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
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 41

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
disk usage reporting tools 27 50
SQL to JSON 14 31
StoredProcedure to JSON query faulty syntax 2 23
Need to 'version' updates to a specific row in a MSSQL server 2 17
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

735 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