Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

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

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
enrique_aeo
Asked:
enrique_aeo
  • 5
  • 4
2 Solutions
 
Jim P.Commented:
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
 
enrique_aeoAuthor Commented:
information is just an example. I know the syntax
0
 
sventhanCommented:
< information is just an example. I know the syntax

What you would like know about the partition then?
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
enrique_aeoAuthor Commented:
As the table to alter that uses the partition scheme?
0
 
sventhanCommented:
Do you like to create a non-partitioned table to partitioned by using alter command?
0
 
enrique_aeoAuthor Commented:
so is my dear friend, can?
0
 
sventhanCommented:
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
 
enrique_aeoAuthor Commented:
ok dear friend, today I do the test at night and you notice how I was, thanks for your contribution. Greetings
0
 
sventhanCommented:
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
 
enrique_aeoAuthor Commented:
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now