2 Replies - 8334 Views - Last Post: 04 April 2015 - 05:36 AM

#1 dag72   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 205
  • Joined: 02-March 11

Creating another table from an existing one

Posted 04 April 2015 - 05:12 AM

I want to create an updated view but first I want to create a 'new_cus' table from the 'customer table using all the existing columns. I use the following syntax which In my opinion is correct, it also works in MySQL but I got the following error in MS SQL Incorrect syntax near 'SELECT'. Expecting ID.

 
CREATE TABLE new_cus AS  SELECT ID, firstName,lastName,email,telePhone,age
FROM customer;




Any ideas as to why this error occurs?

Thank you

Is This A Good Question/Topic? 0
  • +

Replies To: Creating another table from an existing one

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6834
  • View blog
  • Posts: 28,360
  • Joined: 12-December 12

Re: Creating another table from an existing one

Posted 04 April 2015 - 05:14 AM

The syntax for MS SQL is not the same as MySql. MS SQL is

SELECT * INTO NewTable FROM OldTable

INTO Clause (Transact-SQL)

This post has been edited by andrewsw: 04 April 2015 - 05:31 AM

Was This Post Helpful? 2
  • +
  • -

#3 dag72   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 205
  • Joined: 02-March 11

Re: Creating another table from an existing one

Posted 04 April 2015 - 05:36 AM

Thanks great stuff
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1