sql - Array in stored procedure -


i know question has been asked many times not pro in sql need little help.

i have 2 tables - person , contactnumber. person can have many contact numbers need inserted contactnumber table each time make save. thinking having array/collection of contact numbers, person id generated automatically when insert.

what looking on is, how can achieve that? solutions found on net use xml/string delimiter think in case not work. or maybe can not sure how incorporate code.

if 1 have solution please post code too.

thanks in advance

you have table "contactnumber" child of "person". is, don't store them csv, xml or whatever. 1 row per number.

simple example

person. primary key personid
personid, firstname, lastname, gender, ...

numbertype. primary key numbertype. stores things "mobile", "home" etc
numbertypeid, numbertype

contactnumbers. primary key both personid, numbertype
have foreign keys both person , numbertype
personid, numbertypeid, phonenumber

edit, after comment:

with sql server 2008 can use table valued parameters send arrays sql server. thorough article "arrays , lists in sql server 2008" erland sommarskog,

also, don't use @@identity: scope_identity() safer


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -