Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2011
    Posts
    27

    Question Unanswered: getdate() mystery

    when tried execute a stored procedure which uses getdate() function as a variable it produced error message like this
    MSG 102, Level 15, State 1, Line 10
    Incorrect syntax near ')'.
    the query is given below
    GO
    DECLARE @return_value int
    EXEC @return_value = [dbo].[INSERT_CALLBACK_67]
    @PHONE ='46346',
    @CALLBACKTIMEORG = getdate(),
    SELECT 'Return Value' = @return_value
    GO
    then i rewrite the query and executed by declaring getdate() function as given below, it gave correct result

    USE [testy5]
    GO
    DECLARE @return_value int
    DECLARE @dt DATETIME;
    SET @dt = GETDATE();
    EXEC @return_value = [dbo].[INSERT_CALLBACK_67]
    @PHONE = '6757866',
    @CALLBACKTIMEORG = @dt,
    SELECT 'Return Value' = @return_value
    GO
    why this is happening ,i would like know the concept behind

    thanks in advance

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Have you tried removing the comma after the getdate() in your first section of code?
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  3. #3
    Join Date
    Dec 2011
    Posts
    27
    Dear kenn,
    thanku for ur fast reply.
    sorry for the comma problem,actually it was not there in my code. i removed comma, tried agan..
    the same results

    i will qoute the code again
    GO
    DECLARE @return_value int
    EXEC @return_value = [dbo].[INSERT_CALLBACK_67]
    @PHONE ='46346',
    @CALLBACKTIMEORG = getdate()
    SELECT 'Return Value' = @return_value
    GO

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The parameters in an EXECUTE statement must be a value or a variable. Parameters for MS-SQL User Defined functions can be expressions such as GetDate().

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

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