cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to apply

former_member193355
Contributor
0 Kudos

Hi Experts,

We are trying to apply this following function in MS SQL 2000 SP4:



USE [DB1]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
ALTER FUNCTION [dbo].[@DEF_XLL]
(
	-- Add the parameters for the function here
	@Val nvarchar(MAX),
	@PadChar nvarchar(1),
	@Length int
)
RETURNS nvarchar(MAX)
AS
BEGIN

	-- Return the result of the function
	RETURN replicate(@PadChar,@Length-len(@Val)) + @Val

END


but it failed. The error message is "incorrect syntax near returns. Must declare the variable '@Padchar'. Pls give adv. Thx

Rgd,

Steve

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member193355
Contributor
0 Kudos

Hi

Thanks for answer. I manage to resolve this issue.

Rgd,

Former Member
0 Kudos

Could you share your solution?

Former Member
0 Kudos

Hi Steve,

This might relates your error:

>ALTER FUNCTION cannot be used to change a scalar-valued function to a table-valued function, or vice versa. Also, ALTER FUNCTION cannot be used to change an inline function to a multistatement function, or vice versa.

Thanks,

Gordon

former_member193355
Contributor
0 Kudos

Thx for your answer.

I have replaced the word "ALTER" to "CREATE" but it is still the same result.

Is this caused by wrong script I made ? if yes, what would be the solution for this problem ?

Rgd,

Steve

Former Member
0 Kudos

You may check the syntax for function applies to SQL 2000. Something work on higher version may not work here.