Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Store Procedure....

Author  Topic 

moramoga
Starting Member

34 Posts

Posted - 2006-12-05 : 20:11:32
I have this procedure

CREATE Procedure agregarUsuario @idUsuario varChar(20),
@nombre varchar(20),@estado varChar(20),@fechaIngreso datetime,@email varchar(20),
@tipo tinyint,@estacionIngreso varChar(20) AS
DECLARE @password varchar(20)
BEGIN TRAN

SET @password = @idUsuario + @email

INSERT INTO TUsuario
VALUES(@idUsuario,@password,@nombre,@estado,@fechaIngreso,@email,@tipo,@estacionIngreso)


BEGIN
COMMIT TRAN; RETURN 0
END
BEGIN
ROLLBACK TRAN; RETURN 1; END


EXEC agregarUsuario '12345', 'juan', 'activo', 'July 29 1998 2:50 PM', 'blablab@hotmail.com', 1, 'maquina10'


That function insert one user, but what I need here is a function that allows me to control the amount of times the Insert actually runs, based on a parameter sent to the procedure. How do I send this parameter (lets call it numOfUsers) at the time of execution, and how do I get the function to differentiate the many parameters it will receive?

moramoga
Starting Member

34 Posts

Posted - 2006-12-05 : 20:23:26
What I have to do is the same procedure at the one I posted, but it have to receive as a parameter the number of users that I want to register, and all the parameters necessary to insert a user...
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-05 : 23:34:23
Do you mean to say you will pass multiple user details along with @numofusers to the SP and loop in the SP to add those users?

I will suggest run a loop from the front-end and pass single user details. Otherwise, if you are going to pass those details as CSV, refer this:

[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6134[/url]

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-06 : 10:55:30

http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

moramoga
Starting Member

34 Posts

Posted - 2006-12-06 : 19:25:35
I still dont get it how...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-07 : 00:07:38
Did you read the suggested links?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -