Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

How many partitions? Expand / Collapse
Author
Message
Posted Thursday, August 12, 2010 7:36 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, September 8, 2014 9:41 AM
Points: 2,121, Visits: 5,467
I’ve noticed that there is no group by, so I selected the answer with the syntax error. Seems that I was wrong and I lost 3 points. It doesn’t matter that the question did have a syntax error

--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #968178
Posted Thursday, August 12, 2010 7:40 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 30, 2014 7:38 AM
Points: 377, Visits: 432
I also noted the lack of a GROUP BY clause. After “assuming” that it was intended, my first thought was 8 (4 for the table, 4 for the index). Since that wasn’t offered, and the error wasn’t related to the lack of a GROUP BY, I came to 4.

Beer's Law: Absolutum obsoletum
"if it works it's out-of-date"
Post #968182
Posted Thursday, August 12, 2010 8:02 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 9:47 AM
Points: 2,919, Visits: 2,525
Question is terrible!

Took a guess because the error that should have come up was not listed, so had to guess.

Had you at least tested your QOD before posting it, you would have known this.


Steve Jimmo
Sr DBA
“If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
Post #968202
Posted Thursday, August 12, 2010 8:05 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, September 8, 2014 12:46 PM
Points: 989, Visits: 1,824
While I see the flaw in the question, folks don't have to be so mean pointing it out -- that sort of feedback would certainly keep me from offering up a question....
Post #968206
Posted Thursday, August 12, 2010 8:35 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 5:47 AM
Points: 3,951, Visits: 5,180
Can't figure why the GROUP BY is not there.
the stored proc I copied the code from contains:
select $Partition.AccountBalanceDate(AccountBalanceDate) Partition, COUNT(1) RecordsPerPartition
from AccountBalanceMonthEnd with(nolock)
where $Partition.AccountBalanceDate(AccountBalanceDate) between 22 and 25
group by $Partition.AccountBalanceDate(AccountBalanceDate)
order by 1

could one of the admins at SSC please fix this?


____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #968222
Posted Thursday, August 12, 2010 8:59 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, August 29, 2014 11:33 AM
Points: 554, Visits: 1,196
Doh, I choose 0 because I miscounted the number of partitions, I thought there were 21 instead of 28. Anyways, for those interested in a full executable test of the QOD see the following. I found this to be a good question (despite the GROUP BY missing) because I had not worked with partitions. Thanks!

CREATE DATABASE MyDb
ALTER DATABASE MyDB
ADD FILEGROUP Balances
GO
ALTER DATABASE MyDB
ADD FILE (NAME = N'Balances', FILENAME = 'C:\Balances.mdf') TO FILEGROUP Balances
GO
USE MyDB
GO
CREATE PARTITION FUNCTION AccountBalanceDate (DATETIME)
AS RANGE RIGHT FOR VALUES ('2008-03-31',
'2008-04-30','2008-05-31','2008-06-30','2008-07-31',
'2008-08-31','2008-09-30','2008-10-31','2008-11-30',
'2008-12-31','2009-01-31','2009-02-28','2009-03-31',
'2009-04-30','2009-05-31','2009-06-30','2009-07-31',
'2009-08-31','2009-09-30','2009-10-31','2009-11-30',
'2009-12-31','2010-01-31','2010-02-28','2010-03-31',
'2010-04-30','2010-05-31')
GO
CREATE PARTITION SCHEME schemeAccountBalanceDate
AS PARTITION AccountBalanceDate
ALL TO (Balances)
GO
IF EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'MyBalances')
DROP TABLE MyBalances
GO
CREATE TABLE [dbo].MyBalances(
[AccountBalanceRefNo] [uniqueidentifier] NULL,
[AccountRefNo] [uniqueidentifier] NULL,
[AccountBalanceDate] [datetime] NULL,
[CostCentreRefNo] [uniqueidentifier] NULL,
[BalanceCurrencyRefNo] [uniqueidentifier] NULL,
[BalanceAmount] [decimal](18, 3) NULL,
[AccruedInterest] [decimal](18, 3) NULL,
[ExchangeRate] [decimal](15, 7) NULL,
[BaseCurrencyRefNo] [uniqueidentifier] NULL,
[BaseAmount] [decimal](18, 3) NULL,
[BaseAccruedInterest] [decimal](18, 3) NULL)
ON schemeAccountBalanceDate([AccountBalanceDate])
GO
CREATE CLUSTERED INDEX [IX_MyBalances_Date] ON [dbo].[MyBalances]
( [AccountBalanceDate] ASC,
[AccountRefNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON schemeAccountBalanceDate(AccountBalanceDate)
GO

-- Simulate the partitions being loaded
INSERT MyBalances(AccountBalanceDate)
VALUES('2008-03-31'),
('2008-04-30'),('2008-05-31'),('2008-06-30'),('2008-07-31'),
('2008-08-31'),('2008-09-30'),('2008-10-31'),('2008-11-30'),
('2008-12-31'),('2009-01-31'),('2009-02-28'),('2009-03-31'),
('2009-04-30'),('2009-05-31'),('2009-06-30'),('2009-07-31'),
('2009-08-31'),('2009-09-30'),('2009-10-31'),('2009-11-30'),
('2009-12-31'),('2010-01-31'),('2010-02-28'),('2010-03-31'),
('2010-04-30'),('2010-05-31')

select $Partition.AccountBalanceDate(AccountBalanceDate) Partition, COUNT(1) RecordsPerPartition
from MyBalances with(nolock)
where $Partition.AccountBalanceDate(AccountBalanceDate) between 22 and 25
GROUP BY $Partition.AccountBalanceDate(AccountBalanceDate)
order by 1

GO
USE Master
DROP Database MyDB

Post #968256
Posted Thursday, August 12, 2010 11:59 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, July 17, 2014 10:56 AM
Points: 3,924, Visits: 1,607
malleswarareddy_m (8/11/2010)
Hi ,

Is it working for sqls server 2005 or 2008?



It's introduced in 2005 version, but partition is supported only in Enterprise edition. On other editions you will get error.

Msg 7736, Level 16, State 1, Line 2
Partition function can only be created in Enterprise edition of SQL Server. Only Enterprise edition of SQL Server supports partitioning.


SQL DBA.
Post #968466
Posted Thursday, August 12, 2010 1:57 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, September 5, 2014 2:00 PM
Points: 2,163, Visits: 2,191
I saw the missing GROUP BY as well, but since the error option was specific to a different error, I just assumed it got left out somehow. Other than that, nice question.
Post #968545
Posted Thursday, August 12, 2010 2:36 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 12:58 PM
Points: 21,724, Visits: 15,409
Thanks for the question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #968564
Posted Thursday, August 12, 2010 10:49 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:43 AM
Points: 1,938, Visits: 1,162
I know the partitoned table and partioned indexes.but frankly saying

that i thought that with out group by it will work in 2008.but my guess is wrong when i executed in sqlserver 2008.

I did not loaded the data.that's why i had done mistake and put zero as answer. Any how good question about table Partitioning.And also am expecting this type of questions thanks for the author.but next time please do not do mistake in the question.


Malleswarareddy
I.T.Analyst
MCITP(70-451)
Post #968650
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse