Solved

Regarding Filegroup( table prtition) in ms sql server

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL date incremented 11 31
SQL Server - Set Value of Multiple Fields in One Query 10 25
Query Help - MSSQL - Averages 5 27
sql server service accounts 4 26
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.
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.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

810 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