Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 grouping sets

Author  Topic 

anjali5
Posting Yak Master

121 Posts

Posted - 2014-04-24 : 14:33:02
Hi All,
I just installed sql server 2008 on my computer. In order to understand the grouping sets, I got this example from the internet


CREATE TABLE Sales (EmpId INT, Yr INT, Sales MONEY)
INSERT Sales VALUES(1, 2005, 12000)
INSERT Sales VALUES(1, 2006, 18000)
INSERT Sales VALUES(1, 2007, 25000)
INSERT Sales VALUES(2, 2005, 15000)
INSERT Sales VALUES(2, 2006, 6000)
INSERT Sales VALUES(3, 2006, 20000)
INSERT Sales VALUES(3, 2007, 24000)




when I do this

SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY GROUPING SETS((EmpId, Yr), (EmpId), (Yr), ())

I keep getting the error saying:

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'SETS'.

I am not sure what am I doing wrong, but it seems that the new features that sql server 2008 that I installed does not recognize the new features that come with sql server 2008

when I go to help-> about
I see sql server 2008 so I was wondering if I need to do anything to enable these new 2008 features.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-04-24 : 15:19:57
You can check the database to see what version of SQL it s running. 1. The Engine version and 2. the compatibility level:
SELECT @@VERSION

SELECT compatibility_level
FROM sys.databases WHERE name = '<DatabaseName>';
Go to Top of Page

anjali5
Posting Yak Master

121 Posts

Posted - 2014-04-24 : 17:57:41
The database version that I am running is 2005, If I am right clicking on a table and doing
Script Table as -> Create to-> new Query window
then I am getting an error saying "an exception occurred while executing a T-sql statement on batch". the Select permission was denied on the object database_recovery_statis database mssqlsystemresource, schema sys(Microsft sql server, error, 229)

I think this is happening because the database is in 2005 and I am using 2008 sql server management studio. Is there any workaround for this? so that if I right click on the table and say
Script Table as -> Create to-> new Query window
I don't get that error.

I wasn't getting this error when I was using sql server 2005 express edition.

any help will be highly appreciated.
Go to Top of Page

waterduck
Aged Yak Warrior

982 Posts

Posted - 2014-04-24 : 22:05:46
hi, i thinking that you might not have permission to query the table.
Go to Top of Page
   

- Advertisement -