Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I concatenate a String with a Bit (documentTitle+Archive) SQL server 2005

I get the following error when I try to concatenate Operand type clash: text in incompatible with bit Invalid operator for datatype: Operator equals Add, Type equal bit

SELECT
  F.SubmissionId, F.FormId, 
  F.DocumentTitle + F.Archive AS DocumentTitle,
  F.Keywords, F.PublishDate, F.PostedDate, F.ExpiredDate, 
  F.IsFlag, F.IsAdminOnly, F.IsCompleted, F.IsPublished,
  F.CreatedDate, F.AllowComments, 
  CASE WHEN F.Archive = 1 THEN 'Yes' ELSE 'No' END AS Archive, 
  I.ItemId, I.SubmissionId AS Expr1, I.ParamId, I.ParamValue
FROM
  dbo.app_FormSubmission AS F
    INNER JOIN dbo.app_FormSubmissionItems AS I ON 
      F.SubmissionId = I.SubmissionId

1 Answers

you need to convert, run this to see what I mean

declare @i bit
select @i = 1

select 'abc'  + convert(varchar(1),@i) -- fine
select 'abc'  + @i  -- will fail
like image 54
SQLMenace Avatar answered Sep 16 '25 23:09

SQLMenace