Creatin a Tables throuh query in SQL Azure Database using SQL Server

I have a table like this 

Type-  Category -  Subcategory - Amount

A - Sport - Football - 30

A - Sport - Rugby - 25

B- Sport - Football - 10

...

And I want to group them like:

Select Type, Category, Sum(amount) total from table gorup by Select Type, Category;

And save it to a new table. 

So How Can I create a table from another previous one?

June 1st, 2013 1:59am

Hi Ignacio,

First of all, I assume the group by query you are trying to do is something like this.

Select Type, Category, Sum(amount) total from table group by Type, Category;

Since you are saying that you would like to save it to a NEW table, you would normally in SQL Server use the select * into table1 syntax as this will create a new table.  Unfortunately that is not supported in SQL Azure because SELECT INTO statements, does not support the creation of clustered indexes which is required by SQL Azure.  

To work around this you need to create your destination table then call INSERT INTO.

------------------------------------

Cotega - SQL Azure Database Monitoring, Alerts and Task Scheduling

Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2013 3:14am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics