Click here to Skip to main content
15,893,814 members
Articles / Database Development / SQL Server

Top 10 steps to optimize data access in SQL Server: Part V (Optimize database files and apply partitioning)

Rate me:
Please Sign up or sign in to vote.
4.89/5 (52 votes)
8 Nov 2009CPOL15 min read 154.3K   1.4K   102  
As part of a series of articles on several data access optimization steps, this article focuses on organizing files/file-groups and applying partitioning in SQL Server databases.
SET QUOTED_IDENTIFIER OFF;
SET ANSI_NULLS ON;
SET NOCOUNT ON;
GO

IF object_id('<PREFIX,,>_<FUNCTION_NAME,,>') IS NOT NULL

BEGIN
	PRINT 'Dropping Function <PREFIX,,>_<FUNCTION_NAME,,>.';
	DROP FUNCTION <PREFIX,,>_<FUNCTION_NAME,,>;
END

GO

/*
 * ====================================================================
 * BASIC INFORMATION
 * ====================================================================
 *
 * --Project Name			: <PROJECT_NAME,,>
 * --Client Name			: <CLIENT_NAME,,>
 * --Function name			: <PREFIX,,>_<FUNCTION_NAME,,>
 * --Purpose/Function		: <PURPOSE,,>
 * --Author					: <AUTHOR,,>
 * --Start Date(MM-DD-YYYY)	: <START_DATE(MM-DD-YYYY),,>
 *
 * ====================================================================
 * IMPLEMENTATION LOGIC
 * ====================================================================
 *
 * --<IMPLEMENTATION_LOGIC,,>
 *
 * ====================================================================
 * PERFORMANCE (To be filled up by developer,with "Yes" values)
 * ====================================================================
 *
 * --TSQL reviewed				: No
 * --Indexing done properly		: No
 * --Index fragmentation checked: No
 * --Comment					: No comment
 *
 * ===================================================================
 * REVIEW (To be filled up by reviewer,with "Yes" values)
 * ===================================================================
 *
 * --Reviewed by				: <REVIEWER_NAME,,>
 * --Review	date				: 
 * --TSQL reviewed				: No
 * --Indexing done properly		: No
 * --Index fragmentation checked: No
 * --Comment					: No comment
 *
 * ===================================================================*/


-------------------------------------------------------------------------------
--	METADATA AND OTHER MESSAGES ABOVE.
--	BEGIN CREATE STATEMENTS.
-------------------------------------------------------------------------------



CREATE FUNCTION [dbo].[<PREFIX,,>_<FUNCTION_NAME,,>]()
RETURNS TABLE
AS RETURN
(
	--Modify the following TSQL according to your need
	SELECT TOP 5 journalistID,UserName FROM journalists
)
GO

-------------------------------------------------------------------------------
--	END OF CREATE STATEMENTS.
--	METADATA AND SUCCESS/ERROR MESSAGES BELOW.
-------------------------------------------------------------------------------
IF object_id('<PREFIX,,>_<FUNCTION_NAME,,>') IS NOT NULL
BEGIN
	PRINT 'Function <PREFIX,,>_<FUNCTION_NAME,,> created successfully.';	
END
ELSE
BEGIN
	PRINT 'ERROR: Failed to create Function <PREFIX,,>_<FUNCTION_NAME,,>.';
END
GO



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder SmartAspects
Bangladesh Bangladesh
I write codes to make life easier, and that pretty much describes me.

Comments and Discussions