New Posts New Posts RSS Feed: Operand type clash: int is incompatible with datetime2
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Operand type clash: int is incompatible with datetime2

 Post Reply Post Reply
Author
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Topic: Operand type clash: int is incompatible with datetime2
    Posted: 19-Jul-2011 at 2:07pm
I'm updating an old project that still uses DF Classic. I've created a stored procedure and I'm getting the above error.

There is an issue with mapping procedures with temporary tables, so i have a real table that gets returned.

Here is the procedure:


CREATE PROCEDURE procCreateAccountTrx
    @pStartPeriod        int,
    @pEndPeriod            int,
    @pStartYear            int,
    @pEndYear            int,
    @pStartDate            datetime,
    @pEndDate            datetime,
    @pAccounts            varchar(4000)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
   
    DECLARE @StartPeriod        int,
    @EndPeriod        int,
    @StartYear        int,
    @EndYear        int,
    @StartDate        datetime,
    @EndDate        datetime,
    @Accounts        varchar(4000)

    SELECT @StartPeriod = @pStartPeriod,
    @EndPeriod = @pEndPeriod,
    @StartYear = @pStartYear,
    @EndYear = @pEndYear,
    @StartDate = @pStartDate,
    @EndDate = @pEndDate,
    @Accounts = @pAccounts
   
        IF OBJECT_ID (N'[tempTransactions]', N'U') IS NOT NULL DROP TABLE [tempTransactions]
    CREATE TABLE [tempTransactions](
    [AccountId] [int] NOT NULL,
    [SubAccountId] [int] NOT NULL,
    [OpeningBalance] [money] NOT NULL,
    [DebitAmount] [money] NOT NULL,
    [CreditAmount] [money] NOT NULL,
    [Reference] [varchar] (50) NOT NULL,
    [BatchName] [varchar] (50) NOT NULL,
    [Period] [int] NOT NULL,
    [Year] [int] NOT NULL,
    [TransactionDate] [datetime] NOT NULL
    )

    INSERT INTO [tempTransactions]
    exec  CreateAccountTrx @StartPeriod, @EndPeriod, @StartYear, @EndYear, @StartDate, @EndDate, @Accounts
   

    select a.Number, a.Description, s.Code, t.OpeningBalance, t.DebitAmount, t.CreditAmount, t.Reference,
    t.BatchName, t.Period, t.Year, t.TransactionDate
     From [tempTransactions] as t
    INNER JOIN GLAccount as A ON t.AccountId = a.Id
    INNER JOIN GLSubAccount as S on t.SubAccountId = s.Id

   
END
GO


I have never seen this error before and am not too sure how to get past it. Any clues?



Edited by smi-mark - 19-Jul-2011 at 3:13pm
Back to Top
mikewishart View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Posted: 22-Jul-2011 at 3:40pm
Try adding the following line directly after BEGIN

SET FMTONLY OFF

When trying to get information from a stored procedure, the framework calls the proc with all null parameters and with FMTONLY set to ON.  Generally this fails with temp tables.

Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 30-Aug-2011 at 1:41pm
Thanks that's great to know! The initial problem was solved by using another server, but this saves me from having to rename my temp tables/comment stuff out while I map it.


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down