Solved

Regarding Filegroup( table prtition) in ms sql server

Posted on 2010-09-24
2
346 Views
Last Modified: 2012-08-14
Hi,

I want to create t-sql job for automatic creating of new ndf file and automatic dropping/removing same ndf file  based on input parameter (ID and number of rows).  Is it possible in sql server?

I want to add below scripts and conditions in t-sql job:
/*Craete New File Group*/
ALTER DATABASE USERDB Add FileGroup FG_ID
GO

/*Step 2: Add Files to New File Group*/
ALTER DATABASE USERDB
ADD FILE
(
    NAME = [FILE_ID],
    FILENAME = 'C:\SecFiles\ID.ndf',
    SIZE = 5MB    
)
TO FILEGROUP FG_ID;
GO

/*Step 3: Creating a Partition Range Function*/
CREATE PARTITION FUNCTION IDRangePFN (int)
AS RANGE LEFT FOR VALUES
(10,20,30,40,50,60,70)
GO

/*Step 4: Creating a Partition Scheme*/
CREATE PARTITION SCHEME IDRangePS
AS PARTITION IDRangePFN
TO (FG_ID,[PRIMARY])
GO

Condition:
If  id=21 and number of rows (if rowcount=0)---drop ndf file
If  id=21 and number of rows (if rowcount<>0)---no drop ndf file.

after above condition

again creating new table partition function,.schema, range.....

If  id=43 and number of rows (if rowcount=0)---drop ndf file
If   id=43 and number of rows (if rowcount<>0)---no drop ndf file.

Is it possible using t-sql proc?

regards,
Sridhar G









0
Comment
Question by:srinivas_ganamur
[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
2 Comments
 
LVL 23

Accepted Solution

by:
Racim BOUDJAKDJI earned 500 total points
ID: 33753855
<<Is it possible using t-sql proc?>>
Yes.  Yo will need to use dynamic SQL.  Keep in mind the following issue: if aligning the physical storage pruning with logical partition pruning, I would avoid thinking in terms of number of rows but rather think in terms of OS IO ressources. Having a new files created in function of partition ca be quite cumbersome to manage.

Hope this helps...
0
 

Author Closing Comment

by:srinivas_ganamur
ID: 33777528
--
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

733 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