If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > getdate() mystery

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-02-12, 02:36
manuavaran manuavaran is offline
Registered User
 
Join Date: Dec 2011
Posts: 27
Question 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
Quote:
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

Quote:
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
Reply With Quote
  #2 (permalink)  
Old 01-02-12, 07:55
PracticalProgram PracticalProgram is offline
Registered User
 
Join Date: Sep 2001
Location: Chicago, Illinois, USA
Posts: 551
Have you tried removing the comma after the getdate() in your first section of code?
__________________
Ken

Maverick Software Design

(847) 864-3600 x2
Reply With Quote
  #3 (permalink)  
Old 01-02-12, 22:54
manuavaran manuavaran is offline
Registered User
 
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
Quote:
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[INSERT_CALLBACK_67]
@PHONE ='46346',
@CALLBACKTIMEORG = getdate()
SELECT 'Return Value' = @return_value
GO
Reply With Quote
  #4 (permalink)  
Old 01-03-12, 00:11
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
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.
Reply With Quote
Reply

Tags
getdate()

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On