Results 1 to 4 of 4

Thread: [Resolved] SQL2k Scope Problem

Threaded View

  1. #1

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Resolved [Resolved] SQL2k Scope Problem

    Morning, all. Got this problem and can't figure it out - must be missing something extremely simple. Here's the code:

    VB Code:
    1. create function IncAlpha
    2.     -- Increments a single alpha character
    3.     -- uses this sequence ABCDEF..Z
    4.     (@Alpha char(1))
    5.     returns char(1)
    6. as
    7.     begin
    8.        
    9.         declare @RetVal char(1)
    10.    
    11.         if @Alpha is null or @Alpha=''
    12.             set @RetVal='A'
    13.         else
    14.             set @Retval= char(ascii(@Alpha)+1)
    15.  
    16.         return @Retval
    17.  
    18.     end
    19. go

    When I try to compile the function it raises an error on the 'return @Retval' line saying that I must declare it:
    VB Code:
    1. Server: Msg 137, Level 15, State 1, Procedure IncAlpha, Line 17
    2. Must declare the variable '@Retval'.

    What exactly am I doing wrong, here?
    Last edited by yrwyddfa; Jan 26th, 2007 at 04:56 AM.
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width