Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Try to create a table from Select - SqL Server 2008 throws error

Hi I am trying to create a table using inner select statement...

for example:

CREATE TABLE JmxMonSer AS (SELECT * FROM services WHERE monitoring_enabled = 1);

But keep getting error:

Incorrect Syntax near keyword 'AS', Severity 15

please advice

like image 504
Syed Siraj Uddin Avatar asked Mar 18 '26 14:03

Syed Siraj Uddin


1 Answers

I'm almost positive that SQL Server doesn't have a CREATE TABLE AS (SELECT... syntax, but you can use SELECT INTO:

SELECT * 
INTO JmxMonSer
FROM services 
WHERE monitoring_enabled=1

Check the MSDN documentation for proper uses of the CREATE TABLE statement.

like image 168
LittleBobbyTables - Au Revoir Avatar answered Mar 20 '26 08:03

LittleBobbyTables - Au Revoir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!