[dba-SQLServer] Stored Procedure Help Required

Arthur Fuller artful at rogers.com
Fri Feb 27 23:49:25 CST 2004


I have no comment on your reply except to say that you are WAY KEWL
Francisco! You splain everything very nice. Hats off to you!

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of
Francisco H Tapia
Sent: Friday, February 27, 2004 10:58 AM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer] Stored Procedure Help Required


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

SET NOCOUNT ON
CREATE TABLE #Temp1 (PayRollNo varchar(25),
		     JobDate varchar(25))

INSERT INTO #Temp1
EXEC sproc2 @UserID

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

Exec Sproc3 @Param1, @Param2


SET NOCOUNT OFF


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.

-- 
-Francisco


_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list