all groups > sql server programming > november 2003 >
You're in the

sql server programming

group:

UPPER


UPPER Phil
11/26/2003 11:34:40 PM
sql server programming: Hi All,

Once again, thanks for all the reply's on this one!!!
As suggested here is the code that I am trying to run, this
is taken from one of the web site's suggested.

CREATE FUNCTION PROPERCASE
(
@input varchar(8000)
)
RETURNS varchar(8000)
AS
BEGIN
IF @input IS NULL
BEGIN
RETURN NULL
END

DECLARE @output varchar(8000)
DECLARE @ctr int, @len int, @found_at int
DECLARE @LOWER_CASE_a int, @LOWER_CASE_z int, @Delimiter
char(3), @UPPER_CASE_A int, @UPPER_CASE_Z int

SET @ctr = 1
SET @len = LEN(@input)
SET @output = ''
SET @LOWER_CASE_a = 97
SET @LOWER_CASE_z = 122
SET @Delimiter = ' ,-'
SET @UPPER_CASE_A = 65
SET @UPPER_CASE_Z = 90

WHILE @ctr <= @len
BEGIN
WHILE CHARINDEX(SUBSTRING(@input,@ctr,1), @Delimiter) > 0
BEGIN
SET @output = @output + SUBSTRING(@input,@ctr,1)
SET @ctr = @ctr + 1
END

IF ASCII(SUBSTRING(@input,@ctr,1)) BETWEEN @LOWER_CASE_a
AND @LOWER_CASE_z
BEGIN
SET @output = @output + UPPER(SUBSTRING(@input,@ctr,1))
END
ELSE
BEGIN
SET @output = @output + SUBSTRING(@input,@ctr,1)
END

SET @ctr = @ctr + 1

WHILE CHARINDEX(SUBSTRING(@input,@ctr,1), @Delimiter) = 0
AND (@ctr <= @len)
BEGIN
IF ASCII(SUBSTRING(@input,@ctr,1)) BETWEEN @UPPER_CASE_A
AND @UPPER_CASE_Z
BEGIN
SET @output = @output + LOWER(SUBSTRING(@input,@ctr,1))
END
ELSE
BEGIN
SET @output = @output + SUBSTRING(@input,@ctr,1)
END
SET @ctr = @ctr + 1
END

END
RETURN @output
END

----------------------------------------------------------
And these are the error's that I am getting, it's probably
something silly but between this and trying to get my
spidering software to work, giving myself a headache!!!

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'FUNCTION'.
Server: Msg 137, Level 15, State 1, Line 8
Must declare the variable '@input'.
Server: Msg 178, Level 15, State 1, Line 10
A RETURN statement with a return status can only be used in
a stored procedure.
Server: Msg 137, Level 15, State 1, Line 18
Must declare the variable '@input'.
Server: Msg 137, Level 15, State 1, Line 28
Must declare the variable '@input'.
Server: Msg 137, Level 15, State 1, Line 30
Must declare the variable '@input'.
Server: Msg 137, Level 15, State 1, Line 34
Must declare the variable '@input'.
Server: Msg 137, Level 15, State 1, Line 36
Must declare the variable '@input'.
Server: Msg 137, Level 15, State 1, Line 40
Must declare the variable '@input'.
Server: Msg 137, Level 15, State 1, Line 45
Must declare the variable '@input'.
Server: Msg 137, Level 15, State 1, Line 47
Must declare the variable '@input'.
Server: Msg 137, Level 15, State 1, Line 49
Must declare the variable '@input'.
Server: Msg 137, Level 15, State 1, Line 53
Must declare the variable '@input'.
Server: Msg 178, Level 15, State 1, Line 59
A RETURN statement with a return status can only be used in
a stored procedure.

----------------------------------------------------

Thanks Phil
Re: UPPER Phil
11/27/2003 12:28:48 AM
Yes 100% sure, although I didn't set up the SQL here :-)),
shall I take it you just cut and pasted it straight into a
Query Ana. window and the executed it, with no changes?

Thanks Phil

[quoted text, click to view]
Re: UPPER Tibor Karaszi
11/27/2003 12:07:42 PM
Perhaps the database is in 65 or 70 compatibility mode?

--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver


[quoted text, click to view]

Re: UPPER Roji. P. Thomas
11/27/2003 1:34:09 PM
Are you sure that you are using 2000 ;)?
Just curious. It worked fine here.

--
Roji. P. Thomas
SQL Server Programmer ;)
________________________
[quoted text, click to view]

Re: UPPER Roji. P. Thomas
11/27/2003 4:07:18 PM
Yes.
Just copied the function from your post and executed it.

And I can guarantee you that there is no Syntax error in the function.

--
Roji. P. Thomas
SQL Server Programmer ;)
________________________
[quoted text, click to view]

AddThis Social Bookmark Button