Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2011
    Posts
    30

    Unanswered: Operand type clash: int is incompatible with text line 17 1

    I am getting annonyed with this error ... been scratching my head on what can be wrong..

    Code :

    CREATE TABLE #DescriptionReports (
    AccountId int,
    Itemcode text,
    Itemid int,
    Itemid1 int,
    Userfield1 text,
    ContainerItemid int,
    Userfield2 text,
    Userfield3 text,
    Userfield4 text,
    ItemDesc text,
    Rsitemdescription text,
    Rsitemcontent text,
    categorydesc text
    )

    Insert INTO #DescriptionReports (AccountId,Itemcode,Itemid,Itemid1,Userfield1,Cont ainerItemid,Userfield2,Userfield3,Userfield4,ItemD esc,Rsitemdescription,Rsitemcontent,categorydesc)
    SELECT RSITEM.Accountid,RSITEM.ItemCode, main.itemid, main2.itemid,Rsitem.Userfield1,RSitem.ContainerIte mID,Rsitem.Userfield2,Rsitem.Userfield3,Rsitem.Use rfield4,Rsitem.ItemDesc,LEFT(main.rsitemdescriptio n, Len(main.rsitemdescription) - 1) AS
    "Rsitemdescription",LEFT(main2.rsitemcontent, Len(main2.rsitemcontent) - 1) AS
    "Rsitemcontent",RSCATEGORY.CategoryDesc

    FROM
    (SELECT DISTINCT st2.itemid,
    (SELECT st1.itemdesc + ',' AS [text()]
    FROM rsitemdescription st1
    WHERE st1.itemid = st2.itemid
    ORDER BY st1.itemid
    FOR XML PATH ('')) [Rsitemdescription]
    FROM rsitemdescription st2) [Main]
    Right JOIN
    RSITEM ON main.ItemID = RSITEM.ItemID
    left JOIN
    (SELECT DISTINCT st4.itemid,
    (SELECT st3.itemcontent + ',' AS [text()]
    FROM rsitemcontent st3
    WHERE st3.itemid = st4.itemid
    ORDER BY st4.itemid
    FOR XML PATH ('')) [RsitemContent]
    FROM rsitemContent st4) [Main2]
    ON main2.ItemID = RSITEM.ItemID
    Left JOIN
    RSCATEGORY ON RSITEM.CategoryID = RSCATEGORY.CategoryID INNER JOIN
    _RSITEMSTATUS ON RSITEM.ItemStatusID = _RSITEMSTATUS.ItemStatusID
    WHERE ( RSITEM.AccountID = '63' and RSITEM.ObjectID=3 and RSITEM.UserField1 ='beachfield')
    Order by Itemcode

    SELECT
    Itemcode, SUBSTRING (MAX (RSITEMDESCRIPTION), CHARINDEX ('DOCUMENT', MAX (RSITEMDESCRIPTION COLLATE Latin1_General_CS_AS)), CHARINDEX (' PROJECT', MAX (RSITEMDESCRIPTION COLLATE Latin1_General_CS_AS)))
    From dbo.DescriptionReports
    WHERE
    AccountID = 63

    GROUP BY
    ItemCode;

    drop table #DescriptionReports


    It creates the table "DescriptionReportsd"... runs the query below.. and inserts the data.. i have made sure all the fields match in terms of attributes.. int with int and so forth.. but it still gives me this error..

    Any suggestions guys ?
    Last edited by drdre; 02-23-12 at 18:50.

  2. #2
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Quote Originally Posted by drdre View Post
    ...i have made sure all the fields match in terms of attributes.. int with int and so forth.. but it still gives me this error..

    Any suggestions guys ?
    -- "Watson, as I have said, whenever all other possibilities have been ruled out, the improbable, however unlikely, must be the truth."
    No matter how improbable it sounds, somewhere in your code you try to fit an INT into a text column or visa versa.
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •