SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 grouping sets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anjali5
Posting Yak Master

110 Posts

Posted - 04/24/2014 :  14:33:02  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 04/24/2014 :  15:19:57  Show Profile  Reply with Quote
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

110 Posts

Posted - 04/24/2014 :  17:57:41  Show Profile  Reply with Quote
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.

Edited by - anjali5 on 04/24/2014 17:58:50
Go to Top of Page

waterduck
Aged Yak Warrior

Malaysia
965 Posts

Posted - 04/24/2014 :  22:05:46  Show Profile  Reply with Quote
hi, i thinking that you might not have permission to query the table.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000