Column for bar code

Peter_1985 2,736 Reputation points
2021-06-14T03:44:50.693+00:00

Hi,
What kind of data type (of column) is for storing bar code?

Developer technologies Transact-SQL
SQL Server Other
{count} votes

Accepted answer
  1. MelissaMa-MSFT 24,221 Reputation points
    2021-06-14T05:23:06.307+00:00

    Hi @Peter_1985 ,

    Welcome to Microsoft Q&A!

    You could save your barcodes as datatype CHAR(<number of characters>) and not VARCHAR as VARCHAR is characters can vary in length and CHAR data does not.

    If you're using actual product barcodes and they're really strings of 13 digits, a char(13) would probably be the most appropriate data type to store this data.

    If you must store the graphical representation of the barcode for whatever reason, use a VARBINARY(MAX) field - gives you up to 2 GB of binary storage.

    Best regards,
    Melissa


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Olaf Helper 47,436 Reputation points
    2021-06-14T06:18:06.373+00:00

    What kind of data type (of column) is for storing bar code?

    A bar code is just a two dimension representation of data, so the data type depends on your data; in common I would say nvarchar for Unicode text.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.