简体   繁体   中英

SQL-Server - Operand type clash: uniqueidentifier is incompatible with int

When I am executing this code I am having this error. Operand type clash: uniqueidentifier is incompatible with int . What are the solutions to remove this error please? Thanks

CREATE FUNCTION [a01].[udf_isUserActive]
(@AccountID INTEGER)
    RETURNS BIT
    AS
    BEGIN
IF (EXISTS (SELECT  accountID
            FROM    [a01].[tbl_userAccounts]
            WHERE   accountID = @AccountID
                    AND isActive = 1))
    RETURN 1;

RETURN 0;
END;
GO

Most probably tbl_userAccounts has an AccountID of type UNIQUEIDENTIFIER and you are trying to compare @AccountID INTEGER with an UNIQUEIDENTIFIER .

Side note: you should provide the entire context: table schema and function call context. It is a big change that calling the function may also lead to performance problems as scalar functions are called per each selected row.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM