Solved

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

Posted on 2011-02-24
10
404 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.
Comment Utility
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
Comment Utility
information is just an example. I know the syntax
0
 
LVL 18

Expert Comment

by:sventhan
Comment Utility
< information is just an example. I know the syntax

What you would like know about the partition then?
0
 

Author Comment

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

Expert Comment

by:sventhan
Comment Utility
Do you like to create a non-partitioned table to partitioned by using alter command?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:enrique_aeo
Comment Utility
so is my dear friend, can?
0
 
LVL 18

Assisted Solution

by:sventhan
sventhan earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this article I will describe the Backup & Restore 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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now