Solved

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

Posted on 2011-02-24
10
413 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
partitioning database after decade growth 8 79
Replication failure 1 31
How come this XML node is not read? 3 53
What is needed to become a DBA? 7 51
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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