How to modify stored procedures in SQLServer
This article introduces you how to modify the stored procedure in SQLServer, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
Learn how to operate SQLServer stored procedures
Let's assume that we have a table Jobs whose four fields are: job_id,desc,min,max.
Next, let's introduce an example of the operation of a stored procedure:
Create a no-parameter process to query all records
Createprocproc_chaxunasselect*fromjobs-- queries createprocproc_chaxunById@idintasselect*fromjobswherejob_id=@idexecproc_chaxunById@id=2-- according to the number to realize the process of adding processing.
Createprocproc_addJobs@descvarchar (50), @ minint,@maxintasinsertintojobsvalues (@ desc,@min,@max) execproc_addJobs@min=300,@max=1300,@desc='king'-- modifies the name according to the number createprocproc_updateDescById@idint,@descvarchar (50) asupdatejobssetjob_desc=@descwherejob_id=@idexecproc_updateDescById1,'oracle'-- obtains the work name according to the number, with the help of output parameters
Learn how to operate SQLServer stored procedures
The essence of the process with output parameters is to assign values to the output parameters.
Createprocproc_getDescById@idint,@descvarchar (50) outputasselect@desc=job_descfromjobswherejob_id=@id-- first declares a variable of the same data type and accepts the return value declare@strvarchar (50) execproc_getDescById6,@stroutputselect@str-- print data.
On how to modify stored procedures in SQLServer to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.