Results 1 to 7 of 7

Thread: CALL vs EXEC

  1. #1
    Join Date
    Jan 2008
    Posts
    186

    Unanswered: CALL vs EXEC

    Why does this fail
    Code:
    CALL myProc @myVar
    And why does this work
    Code:
    EXEC myProc @myVar
    What's the difference between these two?

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    one is SQL and the other is not.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Jan 2008
    Posts
    186
    That's odd... Because the IDE even highlights "CALL" as being a recognized keyword. And from what I recall, I think other DBMS's (Sybase, mysql?) support CALL

  4. #4
    Join Date
    Feb 2008
    Location
    Columbus, OH
    Posts
    26
    From SQL Server 2000 BOL

    Call
    Executes a void-returning user-defined function.

    Syntax
    Call «UDF Name»

    Remarks
    The Call function executes the registered user-defined function specified by «UDF». This function is designed for use only with void-returning user-defined functions.

    Note If the user-defined function is not registered on the client, the Call function will attempt to call the user-defined function from the Analysis server.

    Example
    Call MyOwnVoidFunction()


    From SQL Server 2005 BOL...

    SQL Server 2005 Books Online (September 2007)
    CALL Statement (MDX)

    Runs a stored procedure that returns a void either in the current scope or optionally on a specified cube.

    Syntax

    CALL SP_Name
    [ (SP_Argument
    [, SP_Argument ,...n]
    ) ]
    [ON Cube_Expression]
    Last edited by flyersfanjd; 07-15-08 at 15:55.

  5. #5
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Just because it is a keyword, don't mean it will do what you expect. STATS_DATE() does not get you a date immediately, and SQRT() does not squirt water at silly users. Trust me. I have tried.

  6. #6
    Join Date
    Jul 2008
    Location
    Texas
    Posts
    17
    Quote Originally Posted by MCrowley
    Just because it is a keyword, don't mean it will do what you expect. STATS_DATE() does not get you a date immediately, and SQRT() does not squirt water at silly users. Trust me. I have tried.


    I wish I could get a six-pack just by calling ABS() over and over again. Then I wouldn't have to use GETDATE() to find a man because I wouldn't be so ROUND().

  7. #7
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Quote Originally Posted by dbguyfh
    Why does this fail
    Code:
    CALL myProc @myVar
    And why does this work
    Code:
    EXEC myProc @myVar
    What's the difference between these two?

    CALL is typically used in DOS batch files to "call" another batch file.

Posting Permissions

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