Solved

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

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

895 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

15 Experts available now in Live!

Get 1:1 Help Now