Click here to Skip to main content
15,943,245 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In sql server 2008, i have a store procedure which has insert statement , now i want to insert multiple records at a time into table via EXEC.

MY Store Procedure:
SQL
insert into tblUser(fullname, email, loginID, password, DOB, question, answers,doc,roleid)
    values (@fullname,@email,@loginID,HASHBYTES('sha512',@password),@dob,@question, @answers, GETDATE(),@roleid )


Now how to insert multiple records via EXEC

SQL
exec dbo.appReg_sp 'Hunain','smile','fdsaf','password','1999-12-1','asas','sasa',1      ; 
now what next ?
Posted
Updated 8-Sep-12 9:18am
v2

Try INSERT ... SELECT with UNION ALL

SQL
create table t (a int, b int)

insert t 
select (1, 2)
union all
select (3, 4)
union all 
select (5, 6)

select * from t -- should bring 3 records


Best wishes,
Pablo.
 
Share this answer
 
Comments
Sandeep Mewara 9-Sep-12 10:28am    
Is that the answer to right question?

Sounds like OP wants multiple insert and your answer is for getting data using UNION. Looks like answer to wrong post.
Pablo Aliskevicius 9-Sep-12 10:35am    
Run the script and see what happens. Hint: I wouldn't be surprised if three records are inserted into one table, even if the word 'insert' appears only once in the script.

Sandeep Mewara 9-Sep-12 14:10pm    
Interesting!

I had doubt if this was posted to correct thread. Looks like it is. Will see.

:thumbsup:
manognya kota 10-Sep-12 3:12am    
5'ed
Pablo Aliskevicius 10-Sep-12 3:57am    
Thanks!
 
Share this answer
 
thanks users....but i solved it my self......i vl use ur solution in future work
 
Share this answer
 
Comments
manognya kota 10-Sep-12 3:12am    
If you have any other solution post it using improve solution as it would be helpful for others.

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