?
Solved

SQL 2000 to SQL 2012 Stored Procedure issue

Posted on 2014-04-07
2
Medium Priority
?
300 Views
Last Modified: 2014-04-24
Below is the Stored Procedure that worked in SQL 2000, but in SQL 2012 throws error -
"Msg 241, Level 16, State 1, Procedure usp_UpdateInteriorDC, Line 51
Conversion failed when converting date and/or time from character string."


USE [ABCDEF]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


ALTER                                       PROC [dbo].[usp_UpdateInteriorDC]
      @intInteriorTransID INTEGER ,
      @chvIssueDate VARCHAR(20),
      @chvRevDate VARCHAR(20) ,
      @chvItemDescription VARCHAR(100),
      @intManufacturerID INTEGER ,
      @chvManufacturerFOB      VARCHAR(50),
      @chvManufacturerLeadTime VARCHAR(20),
      @intFurnishedInstalledFlag INTEGER ,
      @chvSpecialNotations VARCHAR(2000),
      @intUserID INTEGER,
      @chvRevisionNotes VARCHAR(255),
      @intMainInteriorID INTEGER ,
      @chvModifiedTime VARCHAR(20),
      @chrErrCode CHAR(1) OUTPUT,
      @chvErrMsg VARCHAR(200) OUTPUT
AS
DECLARE @chvCurRevDate VARCHAR(20)
BEGIN

      IF @chvRevDate IS NOT NULL AND  @chvRevDate <> ''
            SET @chvCurRevDate = @chvRevDate

      /* Insert Trans Master details based on values passed
         and values generated */
      UPDATE ICS_Interior_Trans_Master
            SET Issue_date = @chvIssueDate,
            Rev_Date = ISNULL(@chvCurRevDate,Rev_Date),
            Item_Description = @chvItemDescription,
            Manufacturer_ID = @intManufacturerID,
            Manufacturer_FOB = @chvManufacturerFOB,
            Manufacturer_Leadtime = @chvManufacturerLeadtime,
            Furnished_Installed_Flag =@intFurnishedInstalledFlag,
            Special_Notations = @chvSpecialNotations,
            Revision_Notes =@chvRevisionNotes,
            Modified_By = @intUserId,
            Modified_Datetime = GetDate()
      WHERE
            Interior_Trans_ID = @intInteriorTransID      AND
            CONVERT(VARCHAR(20), Modified_DateTime,113) = CONVERT(VARCHAR(20), @chvModifiedTime,113)
            

      IF @@ERROR = 0
      BEGIN
            SET @chrErrCode = '0'
            SET @chvErrMsg = dbo.FNGETErrorMessage('ER014')
      END
      ELSE
      BEGIN
            SET @chrErrCode = '2'
            SET @chvErrMsg       =  dbo.FNGETErrorMessage('ER008')
            RETURN
      END

END

I've tried changing the Datetime format, but would appreciate hearing if someone can see what it's issue is????

Thank you,
0
Comment
Question by:urthrilled
[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 Comments
 
LVL 6

Accepted Solution

by:
Ryan Smith earned 1500 total points
ID: 39983694
Change this:

ALTER                                       PROC [dbo].[usp_UpdateInteriorDC]

to

ALTER                                       PROCEDURE dbo.usp_UpdateInteriorDC
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 39983711
Most likely the input value for @chvModifiedTime is not in a valid format.  20 characters is not enough bytes to hold the full string value of format 113, which is "dd mon yyyy hh:mi:ss.mmm".  A first quick shot would be to increase the length of @chvModifiedTime to at least 24 bytes.  The CONVERT in the SELECT will strip the ms anyway.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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.
Suggested Courses

770 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