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 2008 Forums
 Transact-SQL (2008)
 conversion failed from stored procedure to update

Author  Topic 

chapm4
Yak Posting Veteran

58 Posts

Posted - 2012-03-28 : 16:57:04
I read several posts before posting this, but too dense to fix problem.

Stored procedure returns error "Conversion failed when converting date and/or time from character string"

Error comes from eveEventDate column which is datetime, null in both the myTable and myOTable


USE [myDatabase]
GO
/****** Object: StoredProcedure [dbo].[sp_update_myTable] Script Date: 03/28/2012 15:47:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[sp_update_myTable]

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
INSERT INTO dbo.tbl_myTable
SELECT eveID, sitID, eveEventDate, EventDate, inrCode
FROM OPENQUERY(offsiteServer, 'select * from offsiteServer.myOTable.dbo.vw_myOTable') AS HSEL
WHERE (sitID = 11)

END


My other fields are int and nvarchar so what do I need to do for the eveEventDate field to get rid of error?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-28 : 17:04:34
check whats the datatype of eveEventDate in offsiteServer.myOTable.dbo.vw_myOTable

if its varchar make sure format is unambiguos as suggested below

http://visakhm.blogspot.com/2011/12/why-iso-format-is-recommended-while.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -