Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have insert list of values(itemname,session,date) example

aaa mrg 16/4/2013
bbb evng 14/4/2013
ccc dinner 15/4/2013

this values received,but how to insert these values with generate same id for these values in my sqlserver table?.for each insert query should call means,generate another id for list of values..advance thanks

i need this format...

1 aaa mrg 16/4/2013
1 bbb evng 14/4/2013
1 ccc dinner 15/4/2013
Posted
Comments
PrashantSonewane 16-Apr-13 7:04am    
You can do it multiple way. Like maintaining id in code side and passing it with every proc call. But if you are using SQLserver 2008, try using table value type to push whole list as param and insert into one go with one id. You need to learn more about how to use table value type, but i think its worthy.

1 solution

if you want to insert single value for each row for any column in table than use default keyword
ie

create table trail(id default(1),name varchar(50));

and if u want unique values for each row in table than use identity keyword

create table trail(id identity),name varchar(50));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900