Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 getDate Syntax Error - Strange

Author  Topic 

Nick
Posting Yak Master

155 Posts

Posted - 2003-04-09 : 13:41:02
I'm having a really strange problem. I have the following UPDATE statement.

UPDATE tblOpro SET englandShip=cast(getDate() as smalldatetime) 
WHERE oproID=@oproID


And it produces the following error.

'Syntax error converting character string to smalldatetime data type.'

The cast is in there because i was getting the same error prior to using the cast and I thought that might fix it. englandShip is defined as a smalldatetime field in the table.

Also, the statement works in Query Analyzer, but when running it from the sproc is when the error occurs.

Any ideas?



Edited by - Nick on 04/09/2003 13:42:53

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-04-09 : 13:46:30
If it works in Query Analyzer, then the problem is probably somewhere else in the stored procedure. Could we see the stored procedure so that we can determine if the problem is occurring somewhere else?

Tara
Go to Top of Page

Nick
Posting Yak Master

155 Posts

Posted - 2003-04-09 : 13:48:16
Here it is in all of its unoptimized glory. Probably something simple that I'm overlooking.

CREATE PROCEDURE spUpdateOproStatus

@oproID int,
@customerSend bit,
@englandSent bit,
@received bit


AS

DECLARE @orderNumber int

BEGIN TRANSACTION

if @englandSent=1
begin
UPDATE tblOpro SET englandShip=cast(getDate() as smalldatetime) WHERE oproID=@oproID
end


if @customerSend=1
begin
Select @orderNumber=orderID from tblOrders where projectNumber=cast(@oproID as nvarchar(50))

if @orderNumber IS NOT NULL
BEGIN

INSERT INTO tblOrders_Products (orderID, itemID, opQty)
VALUES (@orderNumber, 'OP-6000', '1')

UPDATE tblOpro SET customerShip=cast(getDate() as smalldatetime) WHERE oproID=@oproID

END
end

if @received=1
begin
Select @orderNumber=orderID from tblOpro where oproID=@oproID

UPDATE tblOpro SET received='1' where oproID=@oproID

INSERT INTO tblOrders_Products (orderID, itemID, opQty)
Values (@orderNumber, 'OP-5000', '1')
end

COMMIT TRANSACTION


Go to Top of Page

Nick
Posting Yak Master

155 Posts

Posted - 2003-04-09 : 13:59:04
Nevermind I figured it out. Nothing wrong with getDate. Just me being an idiot. Thanks anyway.

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-04-09 : 14:00:37
Well you gotta give it up....I was looking at it for a while, and I'm like, huh?

OK, what did you do?



Brett

8-)
Go to Top of Page
   

- Advertisement -