0

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:

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

exec dbo.appReg_sp 'Hunain','smile','fdsaf','password','1999-12-1','asas','sasa',1      ; now what next ?
2
Contributors
7
Replies
11
Views
4 Years
Discussion Span
Last Post by HunainHafeez
0

urtivedi, thanks but it isn't a good practice and my store procedure has some other requirements so it doesn't suit that . Thanks anyway
any body else plz ?

0

@utrivedi: sorry my mistake, INSERT statement in Store Procedure wa swrong now i modified it , look at this

**insert into tblAcademicRecord(educationlevel, examname,institution,passingyear,obtainedmarks,totalmarks,grade, percentage, remarks, userid)
    values(@educlvl, @examname, @institution, @Passingyr, @obtainedmarks, @totalmarks, @grade, @percentage, @remarks, @userid), (@educlvl, @examname, @institution, @Passingyr, @obtainedmarks, @totalmarks, @grade, @percentage, @remarks, @userid)**

now tell me that how to pass values to it via EXEC bcz i has now 2 rows of arguments ....have a look

0

urtivedi, thanks but it isn't a good practice and my store procedure has some other requirements so it doesn't suit that . Thanks anyway
any body else plz ?

How you say that it is not a good practise to call procedure twice or n number of times.

inserting 1 row is one operation and inserting 2 rows are 2 distinct operation

in your code if you have n number of rows to insert you have to call your procedure n number of times.

If you feel stored procedure another requirement in your case, you can direct write insert statement in your code itself in loop. this is normal practise. or you can 2 separte stored proceudre one for inserting record only another for your other requirement.

0

@utrivedi : well that was my mistake . now have u seen my recent post ?
new query which i mentioned after modification ? any solution for that ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.