Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Regarding Filegroup( table prtition) in ms sql server

Posted on 2010-09-24
2
Medium Priority
?
354 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 1500 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

610 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