Solved

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

Posted on 2008-06-25
3
2,485 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now