# Partition Table

• ### Question

• Hi:

Does anyone have a sample by using user defined function in the Table Partition Function:

According to the whilepaper:

CREATE PARTITION FUNCTION partition_function_name ( input_parameter_type )
AS RANGE [ LEFT | RIGHT ]
FOR VALUES ( [ boundary_value [ ,...n ] ] )
[ ; ]

boundary_value is a constant expression that can reference variables. This includes user-defined type variables, or functions and user-defined functions

Can anyone help on this: how to reference the user defined function?

Thanks a Lot.

Friday, January 30, 2009 2:48 PM

•
Not sure if I understand the question correctly. Are you asking how to use user defined functions for the boundary value?

CREATE PARTITION FUNCTION (Transact-SQL)

You don't have to use user defined functions here, just a variables or a literal should be fine. If you insist, here is the code snippet to use the function call.

 create function dbo.fn_10times (@i int) returns int as begin return 10*@i end go CREATE PARTITION FUNCTION myRangePF1 (int) AS RANGE LEFT FOR VALUES (dbo.fn_10times(1),dbo.fn_10times(10), dbo.fn_10times(100) );

| Sankar Reddy | http://sankarreddy.spaces.live.com/ |
• Marked as answer by Monday, February 2, 2009 2:21 PM
Sunday, February 1, 2009 10:23 AM

### All replies

•
Not sure if I understand the question correctly. Are you asking how to use user defined functions for the boundary value?

CREATE PARTITION FUNCTION (Transact-SQL)

You don't have to use user defined functions here, just a variables or a literal should be fine. If you insist, here is the code snippet to use the function call.

 create function dbo.fn_10times (@i int) returns int as begin return 10*@i end go CREATE PARTITION FUNCTION myRangePF1 (int) AS RANGE LEFT FOR VALUES (dbo.fn_10times(1),dbo.fn_10times(10), dbo.fn_10times(100) );

| Sankar Reddy | http://sankarreddy.spaces.live.com/ |
• Marked as answer by Monday, February 2, 2009 2:21 PM
Sunday, February 1, 2009 10:23 AM
• Thanks a lot
Monday, February 2, 2009 2:21 PM