Solved

Incorrect syntax near the keyword 'convert' in stored procedure using sql server 2005

Posted on 2008-06-25
3
2,526 Views
Last Modified: 2008-06-30
Hi,

I have the following code that is talking to a sql stored procedure: -

USE [testdata]
GO

DECLARE      @return_value int,
            @NewTestID uniqueidentifier,
            @ErrorCode int,
            @ErrorDescription varchar(255)

EXEC      @return_value = [dbo].[AddNewTestData_v0141]
            @Operator = 13,
            @SNumber = 1689,
            @SerialNumber = N'A08171470380006',
            @DateTimeStart = convert(datetime,'2008-04-22 13:35:00',120),
            @DateTimeStop = convert(datetime,'2008-04-22 13:36:00',120),
            @TestResult = N'1',
            @Assembly = N'AH387775U001',
            @StageRefNum = 945,
            @TransactionNo = 2,
            @NewTestID = @NewTestID OUTPUT,
            @ErrorCode = @ErrorCode OUTPUT,
            @ErrorDescription = @ErrorDescription OUTPUT

SELECT      @NewTestID as N'@NewTestID',
            @ErrorCode as N'@ErrorCode',
            @ErrorDescription as N'@ErrorDescription'

SELECT      'Return Value' = @return_value

GO


It keeps on coming up: -

Msg 156, Level 15, State 1, Line 11
Incorrect syntax near the keyword 'convert'.

The two date parameters are set to datetime.

What am I doing wrong please?

Many Thanks
Lee

0
Comment
Question by:ljhodgett
  • 2
3 Comments
 
LVL 2

Expert Comment

by:pierky
ID: 21864250
Try this:

DECLARE DateTimeStart datetime
DECLARE DateTimeStop datetime
SET DateTimeStart = convert(datetime,'2008-04-22 13:35:00',120)
SET DateTimeStop = convert(datetime,'2008-04-22 13:36:00',120)

EXEC      @return_value = [dbo].[AddNewTestData_v0141]
            @Operator = 13,
            @SNumber = 1689,
            @SerialNumber = N'A08171470380006',
            @DateTimeStart,
            @DateTimeStop,
            @TestResult = N'1',
            @Assembly = N'AH387775U001',
            @StageRefNum = 945,
            @TransactionNo = 2,
            @NewTestID = @NewTestID OUTPUT,
            @ErrorCode = @ErrorCode OUTPUT,
            @ErrorDescription = @ErrorDescription OUTPUT
0
 

Author Comment

by:ljhodgett
ID: 21864415
Hi,

It comes back with the error message: -

Msg 155, Level 15, State 2, Line 1
'datetime' is not a recognized CURSOR option.
Msg 155, Level 15, State 2, Line 2
'datetime' is not a recognized CURSOR option.
Msg 137, Level 15, State 2, Line 6
Must declare the scalar variable "@return_value".

Best Regards
Lee
0
 
LVL 2

Accepted Solution

by:
pierky earned 500 total points
ID: 21864445
Sorry sorry sorry... bad copy/paste, I forgot some "@"

DECLARE @DateTimeStart datetime
DECLARE @DateTimeStop datetime
SET @DateTimeStart = convert(datetime,'2008-04-22 13:35:00',120)
SET @DateTimeStop = convert(datetime,'2008-04-22 13:36:00',120)
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSIS with VPN COnnection 2 78
Return 0 on SQL count 24 30
Insert query into temp tables using Coldfusion 3 23
Need help with a Stored Proc on Sql Server 2012 4 11
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question