Try It Out! Mix Them Up! Input & Output!

    xiaoxiao2021-12-14  28

    --Try to make a script  

     

    --To get full info  

     

    --For a random Female (or Male) student.

     

    --tfu@isb.bj.edu.cn

     

    if object_id('outputtest') is not null   

    drop proc outputtest   

    go   

    create proc outputtest   

    @input_Gender Varchar(10),   

    @Output_Student_number int output 

    As   

    declare @FunctionVariable varchar(50)   

    set @FunctionVariable='9'   

    select Top 1 @Output_student_number=student_number  

    from students    

    where  

    grade_level=@FunctionVariable 

    and 

    Gender=@input_Gender 

    order by newid()   

    select @Output_student_number as IN_PROC_STDNUM   

      

    ------------------------------------------------------------------------------ 

     

    declare @input_new_Gender varchar(10) 

    declare @output_new_Student_number int 

    Set @input_new_Gender='F' 

    exec outputtest    

    @input_new_Gender,   

    @output_new_Student_number output 

    select    

    @Output_new_Student_number as OUTPUT_STUDNUM  

    select * from students s   

    where s.Gender=@input_new_Gender 

    and s.student_number=@output_new_Student_number 

     

     

     

     

    转载请注明原文地址: https://ju.6miu.com/read-963090.html

    最新回复(0)