Results 1 to 4 of 4

Thread: [Resolved] SQL2k Scope Problem

  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

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: SQL2k Scope Problem

    Is is case sensitive RetVal / Retval ?

  3. #3

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

    Re: SQL2k Scope Problem

    Yes it was - many thanks for helping me, aka the village idiot. Now I'll just have to rebuild the server and take the binary collation off. Don't trust them techie guys, chaps.

    Don't trust 'em: Do it yourself.

    Many thanks again. Cheers
    "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

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [Resolved] SQL2k Scope Problem

    I have never used a server that was case-sensitive - what a nightmare that must be!

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

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