Solved

SQL 2000 to SQL 2012 Stored Procedure issue

Posted on 2014-04-07
2
290 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 500 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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

739 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