We help IT Professionals succeed at work.

how to store "sucess" and "Failure"

  i want to store  "Sucess" or "Failure" as values of specific column  called "Column1" in the table "Table1" in SQL server.
Can you please let me know which data type i should use for "Column1".



Watch Question

simply you can use varchar or char data type for that.

But, also you can use smallint or tinyint and store value 1 or 0 in the field. later you have to treat this 1 and 0 in your query as "Success" and "Failure"

- Deepak Lakkad
SQL Server DBA
Top Expert 2011
I would say BIT, this store true/false i.e 1/0. if you use varchar or char or smallint or tinyint, there is a chance of other values appart from 1/0 to get stored in there, and to restrict storing other values you need to add check constraint to the column. So every insert/update makes additional overhead of checking whether the right values are inserted or not and cause performance problems.

So better go with BIT.
If you are sure that you always save  "Success" or "Failure" and there is no chance of any other value then BIT data type would be good. You can use it as follows
 "Sucess" =1
  If there is chance other value may added in future than you use int field corresponding to varchar char field where int fields contains id and varchar field contains actual text like  "Sucess" or "Failure".
  And finally if you want to save exact text like  "Sucess" or "Failure" then use varchar as datatype.

If you want to store only Sucess and failure words in database you can use char. if you can change the values by using code then go for bit and display in userinterface  as