[dba-SQLServer] Stored Procedure Help Required

Francisco H Tapia my.lists at verizon.net
Fri Feb 27 12:58:21 CST 2004

paul.hartland at fsmail.net wrote:

>To all,
>I’m sure this is possible, but being quite a novice at Stored Procedures (i.e. able to write simple SELECT, INSERT, DELETE & UPDATE procs) I don’t know how to go about this.
>I want to write an SP which I call from Visual Basic which sends the current UserID (I know how to do this bit) I then want the SP to call another SP using the UserID I passed to it.  Then I want to use the fields PayrollNo and JobDate from the second SP to execute a third SP passing the parameters PayrollNo and Jobdate.
this is easy enough w/o output parameters (if you don't want to get into it)

EXEC Sproc1 (@userid as varchar(20)) AS

CREATE TABLE #Temp1 (PayRollNo varchar(25),
		     JobDate varchar(25))

EXEC sproc2 @UserID

DECLARE @Param1 as varchar(25), @param2 as Varchar(25)
SELECT @Param1 = Field1, @param2 = Field2 From #Temp1

Exec Sproc3 @Param1, @Param2


by the way if you're practicing your sprocs try looking in QA (sql server 2000) and using the tools there, it has simple things such as it will create an select/insert/update/delete statement for a table/view/sproc.  check itout you'll find that you'll be writing more and more complex sprocs in no time.... using gui tools like in EM and Access' QBE I've found are a terrible crutch cuz normally you don't take the time to fully examine the sql.


More information about the dba-SQLServer mailing list