Solved

create a new table from view

Posted on 2014-01-11
3
316 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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now