2008 r2 t-sql call stored procedure with 3 parameters

  • In t-sql 2008 r2 I need execute a stored procedure called StudentData and pass 3 parameter values to the stored procedure. The stored procedure will then return 5 values that are needed for the main sql. My problem is I do not know how to have the t-sql call the stored procedure with the 3 parameter values and pass back the 5 different unique data values that I am looking for.

    The basic dataset is the following:

    SELECT SchoolNumber,

    SchoolName,

    StudentNumber,

    from [Trans].[dbo].[Student]

    order by SchoolNumber,

    SchoolName,

    StudentNumber

    I basically want to pass the 3 parameters of SchoolNumber, SchoolName, and StudentNumber to the

    stored procedure called StudentData from the data I obtain from the [Trans].[dbo].[Student]. The 3 parameter values will be obtained from the sql listed above.

    The columns that I need from the stored procedure called StudentData will return the following data columns

    that I need for the report: StudnentName, StudentAddress, Studentbirthdate, StudentPhoneNumber, GuardianName.

    Thus can you show me how to setup the sql to meet this requirement I have?

  • Output parameters are your friend:

    http://technet.microsoft.com/en-us/library/ms187004(v=sql.105).aspx

  • The columns that I need from the stored procedure called StudentData will return the following data columns

    that I need for the report: StudnentName, StudentAddress, Studentbirthdate, StudentPhoneNumber, GuardianName.

    Thus can you show me how to setup the sql to meet this requirement I have?

    Where're the StudnentName, StudentAddress, Studentbirthdate, StudentPhoneNumber, GuardianName coming from?

    If they're in the same table, you can get it just running that query with those fields added.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply