Table partition

Posted by: cadarsh89

Tagged in: Untagged 

-- Table partitiion
create database partition1
(
name = 'partition',
filename = 'c:sqllabpartition.mdf',
)
create partition function fn1(int) as range left for values  (10,100,1000)   --Error:Partition function can only be created in Enterprise edition of SQL Server. Only Enterprise edition of SQL Server supports partitioning.
alter databse partition addfilegroup fg1
alter databse partition addfilegroup fg2
alter databse partition addfilegroup fg3
alter databse partition addfilegroup fg4

create partition scheme sch1
as partition fn1 to (fg1,fg2,fg3,fg4)

alter database partition add file
(name = 'file',
filename = 'c:sqllab ile1.mdf',
size = 10mb) to filegroup fg1

select * from sys.filegroups

create table sales (c1 int,c2 varchar(10)) on sch1(c1)
insert into sales values (1,'name')
insert into sales values (2,'name')
insert into sales values (9,'name')
insert into sales values (10,'name')
insert into sales values (11,'name')
--gives error as there is no file defined in fg2(10-100)