I have a user function that returns a BIT calle dbo.IsPartReady.
I am trying to use the function inside of a trigger as follows:
SET @railReady = dbo.IsPartReady(1,@curPartiId);
SET @frameReady = dbo.IsPartReady(2,@curPartiId);
SET @dryAReady = dbo.IsPartReady(3,@curPartiId);
SET @dryBReady = dbo.IsPartReady(4,@curPartiId);
IF ( (@railReady AND @frameReady ) OR ( @dryAReady AND @dryBReady ) )
I’m getting the following error in the IF statement:
An expression of non-boolean type specified in a context where a condition is expected, near ‘AND’.
What am I doing wrong ?
BIT data type in SQL Server is not a boolean it is an integer. You have to compare the value of the variable with something to get a boolean expression. BIT can have the value 0, 1 or NULL.
http://msdn.microsoft.com/en-us/library/ms177603.aspx