Solved

Regarding Filegroup( table prtition) in ms sql server

Posted on 2010-09-24
2
349 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

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.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

689 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