Pergunta

I would like to store the CONTENT_LENGTH http request header value in my SqlServer database.

What is the best database column datatype to store it? I was planning store it as a varchar( SIZE ).

I could handle it as BIGINT, max value = 9223372036854775807, but what I'm trying to do is store it as a varchar, in this case LENGTH(9223372036854775807) = 19, so varchar(19) , is it ok?

Any help or idea about it?

Foi útil?

Solução

No, you shouldn't be storing as VARCHAR type cause it's Numeric type.

As per W3C RFC 2616-sec14.13 specification

The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET.

An example is

   Content-Length: 3495

You can see the full spec here Content-Length

A look here for complete list of SQL Server supported data types Data Types (Transact-SQL)

So essentially you should be storing as INT or BIGINT data type in SQL SERVER

Outras dicas

According to this, you could store it as a bigint since there is no upper limit to the size of the number that you can get. It would be good to also certify its > 0.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top