Solved

sql server 2008: as a partition a table with 40.000 rows?

Posted on 2011-02-24
10
410 Views
Last Modified: 2012-05-11
CREATE PARTITION FUNCTION pfPart1 (int)
AS RANGE LEFT FOR VALUES (10000, 20000, 30000, 40000)

--5
CREATE PARTITION SCHEME psPart1
AS PARTITION pfPart1
TO (pfg01, pfg02, pfg03, pfg04, pfg05)


--6
Create Table tPart1
(IdPart Int, Nombre Varchar(20), Cantidad Int, Valor Decimal(12,5))

I have a table without partitions, which has 40,000 rows
 I created the function and partition scheme
 As the table to alter that uses the partition scheme?
0
Comment
Question by:enrique_aeo
  • 5
  • 4
10 Comments
 
LVL 38

Expert Comment

by:Jim P.
ID: 34976665
I'm sorry -- but I've processed more than one 40K row table without a burp. (And still had room for dessert.)

Do you want to partition for future growth?
0
 

Author Comment

by:enrique_aeo
ID: 34979421
information is just an example. I know the syntax
0
 
LVL 18

Expert Comment

by:sventhan
ID: 34982568
< information is just an example. I know the syntax

What you would like know about the partition then?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:enrique_aeo
ID: 35010284
As the table to alter that uses the partition scheme?
0
 
LVL 18

Expert Comment

by:sventhan
ID: 35010396
Do you like to create a non-partitioned table to partitioned by using alter command?
0
 

Author Comment

by:enrique_aeo
ID: 35010408
so is my dear friend, can?
0
 
LVL 18

Assisted Solution

by:sventhan
sventhan earned 500 total points
ID: 35010911
Drop your clustered index and create it with the partitioned function/schema.


CREATE  CLUSTERED INDEX [indexname]
ON [dbo].[tablename]([partitioncolumn]) ON  partfunction_name ([partitioncolumn])
GO




http://technet.microsoft.com/en-us/library/ms175864.aspx

 Converting a Nonpartitioned Table to a Partitioned Table
You can turn an existing nonpartitioned table into a partitioned table in one of two ways.

One way is to create a partitioned clustered index on the table by using the CREATE INDEX statement. This action is similar to creating a clustered index on any table, because SQL Server essentially drops the table and re-creates it in a clustered index format. If the table already has a partitioned clustered index applied to it, you can drop the index and rebuilding it on a partition scheme by using CREATE INDEX with the DROP EXISTING = ON clause.

For information about clustered indexes, see Clustered Index Design Guidelines.

Another way is to use the Transact-SQL ALTER TABLE SWITCH statement to switch the data of the table to a range-partitioned table that has only one partition. This partitioned table must already exist before the conversion occurs, and its single partition must be empty. For more information about switching partitions, see Transferring Data Efficiently by Using Partition Switching. After the table is modified as a partitioned table, you can modify its partition function to add partitions, as described previously in Modifying a Partition Function.

To convert an existing table to a partitioned table
0
 

Author Comment

by:enrique_aeo
ID: 35011307
ok dear friend, today I do the test at night and you notice how I was, thanks for your contribution. Greetings
0
 
LVL 18

Accepted Solution

by:
sventhan earned 500 total points
ID: 35017555
This should be on partition scheme... I changed the code for you...

CREATE  CLUSTERED INDEX [indexname]
ON [dbo].[tablename]([partitioncolumn]) ON  partition_scheme_name([partitioncolumn])  <============ partition_scheme
GO
0
 

Author Comment

by:enrique_aeo
ID: 35017899
CREATE TABLE [dbo].tabla_demo
(  
id int identity,    
c varchar(200) NULL
)
go

declare @i int
set @i = 1
while @i<=10 -- Luego 1.000.000 filas
begin        
      INSERT INTO dbo.tabla_demo    
      SELECT top (50000)      
               replace(cast(NEWID() as varchar(100)), '-','') + REPLICATE('a', 200-32)    
      FROM AdventureWorks.Sales.SalesOrderHeader   CROSS JOIN AdventureWorks.Sales.SalesOrderDetail
      print cast (@i as varchar(100))  
      set @i=@i+1
end

CREATE PARTITION FUNCTION pfPartEE (int)
AS RANGE LEFT FOR VALUES (10000, 20000, 30000, 40000)

--5
CREATE PARTITION SCHEME psPartEE
AS PARTITION pfPartEE
TO (pfg01, pfg02, pfg03, pfg04, pfg05)



CREATE  CLUSTERED INDEX [idx_id]
ON dbo.tabla_demo([id]) ON  psPartEE([id])

SELECT $PARTITION.pfPartEE(id) AS Particion,
COUNT(*) AS NumeroRegistros FROM tabla_demo
GROUP BY $PARTITION.pfPartEE(id)
ORDER BY Particion
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question