| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

11-28-11, 16:16
|
|
Registered User
|
|
Join Date: Nov 2011
Posts: 3
|
|
|
Date Conversion Issue
|
|
Hello programmers. I was running a SP for the past couple of years. I dropped it to create it again with an additional column included (cmpcode). Now I get the below error message. Can someone help me with resolving this? Thank you. See attached.
CODE:
CREATE PROC BLTextData
@pay_date DATETIME
AS
DELETE zoas_apcheckinfo
INSERT zoas_apcheckinfo
SELECT cmpcode,
invno,
vendor,
paydate,
doccode,
checkno,
invamt,
checkamt,
status,
duedate,
year,
period,
docdate,
vendorname,
docnum
FROM oas_apcheckinfo
WHERE paydate = @pay_date
ORDER BY vendor
ERROR:
Msg 257, Level 16, State 3, Procedure BLTextData, Line 11
Implicit conversion from data type datetime to smallint is not allowed. Use the CONVERT function to run this query.
|
|

11-28-11, 16:53
|
|
Registered User
|
|
Join Date: Sep 2001
Location: Chicago, Illinois, USA
Posts: 551
|
|
So the error says that you are trying to push a datetime value into a smallint field.
Is it possible that you are accidentally doing that???
__________________
Ken
Maverick Software Design
(847) 864-3600 x2
|
|

11-28-11, 19:26
|
|
Registered User
|
|
Join Date: Nov 2011
Posts: 3
|
|
|
|
Ok, thanks for the reply. I figured it out. I had one of my columns out of order.
|
|

11-30-11, 03:43
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 1,279
|
|
You just found out why it is better to write INSERT scrpits like this:
Code:
INSERT zoas_apcheckinfo (cmpcode, invno, vendor,
paydate, doccode, checkno,
invamt, checkamt, status,
duedate, year, period,
docdate, vendorname, docnum)
SELECT cmpcode, invno, vendor,
paydate, doccode, checkno,
invamt, checkamt, status,
duedate, year, period,
docdate, vendorname, docnum
FROM oas_apcheckinfo
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|