Piotr Lepka
Piotr Lepka

Reputation: 21

What kind of SQL Server datatype should be used?

What datatype in SQL Server should be used to store 800 decimal values (0000-9999) in one row. Something like this:

0144,0152,0142,0136,0149,0147,0143,0123,0121,0128,0134,0139,

Is there any array in SQL Server?

Thank you!

Upvotes: 1

Views: 105

Answers (1)

David Browne - Microsoft
David Browne - Microsoft

Reputation: 88851

Normally you would use a separate table with a SMALLINT to store multiple values.

If you want to store them as a single column value, use VARCHAR(MAX) and store JSON, or store them as a byte array in VARBINARY(MAX). If you store them as VARBINARY(MAX) SQL Server won't be able to query the individual values, and you'll have to fetch the blob back to your application to do anything with the individual values.

Upvotes: 2

Related Questions