How to save array of integer numbers in a column in SQL Server 2005

我是研究僧i 提交于 2020-01-16 18:44:30

问题


I have a table in SQL Server 2005 with the following properties:

Users (UserID, Username, Password)   where UserID is primary key

I want to save an array of integer numbers in the password attribute in the Users table.

--------------------
 0    1    2    3  
--------------------
1543 6543 7658 8765
--------------------

I plan to save this into the password column.

On the other hand I use pictures instead of texts for password and each picture has a code (4 digit) and a password include 4 picture that produce 16 digit. I want to save these 16 digits (array of Ints) into the Password column

please help me.

thanks


回答1:


In general arrays are saved in SQL tables as another table, one table row per array element.

But that does not look though like an array of ints, that looks more like 16 byte vector, probably an MD5 digest. Make a VARBINARY(20) column (this way you can switch to SHA1 without changing the column type) and store the byte array as a ... byte array. See SqlBytes for how to manipulate BINARY and VARBINARY columns in the client.



来源:https://stackoverflow.com/questions/4532879/how-to-save-array-of-integer-numbers-in-a-column-in-sql-server-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!