开发者

store array or vector in ms sql server 2005

开发者 https://www.devze.com 2023-03-14 08:40 出处:网络
Anyone knows how to store array or vector in ms sql server 2005? There is way to store array in oracle db but I don\'t know about sql server.

Anyone knows how to store array or vector in ms sql server 2005? There is way to store array in oracle db but I don't know about sql server.

eg:

st_id [1234]
st_mk [(12),(34),(67),(45)]

st_id [3456]
st_mk [(12),(34)]开发者_JAVA百科

Like above st_mk (the vector size) is not same.

Please help me...!!


In a separate child table?

create table Vector(st_id int primary key)

create table VectorElement
(
    st_id int references Vector(st_id),
    element int
)

create index IX_VectorElement_st_id on VectorElement(st_id)

insert Vector
values(1234)

insert VectorElement
select 1234, 12 union all
select 1234, 34 union all
select 1234, 67 union all
select 1234, 45

Another option to store it as a string (varchar), but this is less efficient and you would need to parse it.

Another option is to use XML type column.

0

精彩评论

暂无评论...
验证码 换一张
取 消