Shelton Thompson
Shelton Thompson

Reputation: 19

SQL Server Computer Column Using a Bit Column as the Where Clause

I am trying to create a computed column in SQL Server Management Studio off of a bit column but it keeps erroring out stating "Erro Validating the formula for column..."

I have tried the following:

CASE WHEN AribaSupplier_PotentialforCatalogFlag=1 THEN "True" ELSE "False" END
CASE WHEN AribaSupplier_PotentialforCatalogFlag='1' THEN "True" ELSE "False" END
CASE WHEN AribaSupplier_PotentialforCatalogFlag=True THEN "True" ELSE "False" END
CASE WHEN AribaSupplier_PotentialforCatalogFlag='True' THEN "True" ELSE "False" END

Upvotes: 0

Views: 74

Answers (3)

forpas
forpas

Reputation: 164089

Since this is SQL Server, there is IIF():

IIF(AribaSupplier_PotentialforCatalogFlag  = 1, 'True', 'False')

Upvotes: 1

Yogesh Sharma
Yogesh Sharma

Reputation: 50163

You need single quote for string constant :

(CASE WHEN AribaSupplier_PotentialforCatalogFlag  = 1
      THEN 'true' ELSE 'false'
      WHEN AribaSupplier_PotentialforCatalogFlag = 'True' 
      THEN 'True' ELSE 'False'
 END)

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1269623

String constants should be in single quotes, not double quotes. So try:

CASE WHEN AribaSupplier_PotentialforCatalogFlag = 1 THEN 'True' ELSE 'False' END

Upvotes: 3

Related Questions