locked
Need Help with Error message RRS feed

  • Question

  • I'm using Report Server from SQL 2012, and have set up the below stored procedure between to unrelated tables, but when executing it, I get the following error:

    Operand type clash: text is incompatible with date

    I'm thinking that I need to convert the dates, but not sure how or where in the code... any help would be appreciated.

    The SP code is:

    GO
    ALTER Procedure [dbo].[spDailyTripReport]
    
    (
    	 @Start	date,
    	 @Visit date
    )
    AS
    SELECT 
    	CompanyName,
    	PointContact,
    	city,
    	DateCreated
     from Clients
    where DateCreated = @Visit
    Union
    Select 
    	date1,
    	num_places,
    	city,
    	notes
     from Trip
    where date1 = @Start;


    Jill Trehearne

    Monday, July 1, 2013 7:24 PM

Answers

  • You are UNIONing 2 different queries.  They must both return the same fields in the same order with the same data types.

    Field 4 in the first is "DateCreated" I assume a date.  Field 4 in the second is "notes" which I assume is a text field.

    • Proposed as answer by Mike Yin Tuesday, July 2, 2013 2:56 AM
    • Marked as answer by Mike Yin Friday, July 5, 2013 9:45 AM
    Monday, July 1, 2013 7:43 PM

All replies

  • You are UNIONing 2 different queries.  They must both return the same fields in the same order with the same data types.

    Field 4 in the first is "DateCreated" I assume a date.  Field 4 in the second is "notes" which I assume is a text field.

    • Proposed as answer by Mike Yin Tuesday, July 2, 2013 2:56 AM
    • Marked as answer by Mike Yin Friday, July 5, 2013 9:45 AM
    Monday, July 1, 2013 7:43 PM
  • Thanks.. that helped me understand my dilemma...

    Jill Trehearne

    Tuesday, July 2, 2013 5:50 PM