Solved

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

Posted on 2008-06-25
3
2,563 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

756 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