Welcome to the microsoft TSQL Q&A forum!
Sorry, your description is not very clear to me. But it seems that your question is about stored procedures with input parameters. Here is a simple example of creating a stored procedure with input parameters, which may be useful to you:
--Create test data: student information table and book information table
drop table if exists student
drop table if exists book
create table student
(stuID char(10) primary key,
stuName varchar(30) not null,
major varchar(50) not null)
create table book
(BID char(10),
Title char(50),
Author char(20) )
insert into student values(1001,'linlin','Computer'),
(1002,'Poplar','Computer'),
(1003,'Eyre','English'),
(1004,'Julie','Business Administration'),
(1005,'linlin','Mathematic')
insert into book values('B001','Jane Eyre','charlotte browntie'),
('B002','Wuthering Heights','Emily Jane Bronte'),
('B003','The Lady of the Camellias ','Alexandre Dumas fils'),
('B004','The Wretched','Victor Hugo'),
('B005','Notre Dame Cathedral','Victor Hugo')
select * from student
select * from book
--Stored procedure with input parameters
--Check whether there are the same stored procedures in the database, delete if there are
if exists (select * from sysobjects where name='b_stu')
drop procedure b_stu
go
--Create a stored procedure that enters the student id and returns the student’s book borrowing status
create procedure b_stu
@ID char(10) --Define input parameters
as
select stuName=(select stuName from student where stuID=borrow.BstuID ),
Title=(select Title from book where BID=borrow.BID), Ttime=Ttime,Btime=Btime
from borrow where BstuID=@ID;
--Call stored procedure
execute b_stu @ID='1005'
If this does not solve your problem, please provide your stored procedure code and related tables and data (including CREATE and INSERT INTO statements), as well as the problem you encountered.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.