mburk1968
asked on
Stored Procedure Error SQL 2005
I receive the following error when trying to execute my Stored Procedure.
Error converting data type nvarchar to datetime.
The field in my Table is a datetime. I have placed the query below as well as the code that I am using to execute the query is at the very bottom.
Error converting data type nvarchar to datetime.
The field in my Table is a datetime. I have placed the query below as well as the code that I am using to execute the query is at the very bottom.
USE [EXPORTHpixPROD]
GO
/****** Object: StoredProcedure [dbo].[spGetMonthlyEvaluationByEventID] Script Date: 03/24/2011 07:25:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Michael Burk
-- Create date: 03232011
-- Description: Report that selects Evaluations by EventID and Month
-- =============================================
ALTER PROCEDURE [dbo].[spGetMonthlyEvaluationByEventID]
-- Add the parameters for the stored procedure here
(@EventID AS BIGINT,
@FromDate as DATETIME,
@ToDate as DATETIME)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT DISTINCT
CME_Parsed_Survey_XML.SurveyID
,CME_Parsed_Survey_Results_XML.SurveyID
,CME_Parsed_Survey_XML.SurveyDate
,CME_Parsed_Survey_XML.EventID
,CME_Parsed_Survey_XML.LicenseNumber
,CME_Parsed_Survey_Results_XML.QuestionID
,CME_Parsed_Survey_Results_XML.QuestionText
,CME_Parsed_Survey_Results_XML.AnswerTextID
,CME_Parsed_Survey_Results_XML.AnswerText
,CME_Parsed_Survey_Results_XML.AnswerText2
,CME_Parsed_Registration_XML.Designation
,CME_Parsed_Registration_XML.FirstName
,CME_Parsed_Registration_XML.LastName
,CME_Parsed_Registration_XML.Title AS Suffix
,CME_Courses.Title AS Title
,CME_Courses.URL
FROM CME_Parsed_Survey_XML INNER JOIN
CME_Parsed_Survey_Results_XML ON CME_Parsed_Survey_XML.SurveyID = CME_Parsed_Survey_Results_XML.SurveyID
INNER JOIN
CME_Parsed_Registration_XML ON CME_Parsed_Survey_XML.LicenseNumber = CME_Parsed_Registration_XML.MedicalLicenseNumber
INNER JOIN
CME_Courses ON CME_Parsed_Survey_XML.EventID = CME_Courses.EventID
WHERE SurveyDate between (@FromDate) and (@ToDate)
END
------------------------------------------------------------------------------------------------
Code to execute query
------------------------------------------------------------------------------------------------
USE [EXPORTHpixPROD]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[spGetMonthlyEvaluationByEventID]
@EventID = 87895,
@FromDate = N'02012011',
@ToDate = N'02312011'
SELECT 'Return Value' = @return_value
GO
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try changing the format of the dates that you are passing in.
from 02012011 to 02/01/2011
from 02012011 to 02/01/2011
ASKER