Reputation: 11
I would like to store in a column, a userID
which goes with this format "ED25
" Which data type should I use? Additional info to make that possible is welcomed.
Upvotes: 0
Views: 2462
Reputation: 16958
I think you need to use a numeric data type like bigint
.
So, I suggest you to use a mixed mode of varbinary
and bigint
like this:
SELECT CONVERT(bigint, CONVERT(varbinary,'ED25'))
Result:
1162097205
And for decoding it:
SELECT CONVERT(varchar, CONVERT(varbinary, 1162097205))
Upvotes: 0
Reputation: 135
You should use varchar(50)
. You can combine ED and # using C# or other language of your choice. In C# you will generate an SQL command like:
INSERT INTO yourtablename(ED) VALUES ('ED"+your_int.ToString()+"')
Upvotes: 0
Reputation: 27424
Actually you are using strings, so you should use either a varchar(n)
or text
.
If you use PostgreSQL you can use text
, otherwise you can use varchar(n)
, where n
is the maximum possible size of your strings.
Upvotes: 1