Stored procedure

xiaoxiao2021-03-06  76

usesmtdata go / * Delete process * / dropprocedureusp_search_user go / * creation * / createprocedureusp_search_user @usernamevarchar (32) as select @ username = @ username '%' selecttop10usernameas user name, passwordas password fromnormaluser whereusernamelike @ username orderby user name DESC GO / * Modify process ALTER * / ALTERprocedureusp_search_user @usernamevarchar (32) as select @ username = @ username '%' selecttop10usernameas user name, passwordas password fromnormaluser whereusernamelike @ username orderby username DESC a first introduce what is stored procedure stored procedure using SQLServer provided The program written by the TRANACT-SQL language. The TRANACT-SQL language is SQL Server provides a language designed to design a database application, which is the primary programming interface between the application and the SQL Server database. It is better than the Informix-4GL language that Pro-SQL and Informix in the Oracle Database system is in the INFORMIX-4GL language. Such languages ​​provide the following functions, allowing users to design programs that meet the reference requirements: 1), variables 2), ANSI-compatible SQL commands (such as SELECT, UPDATE ....) 3), general flow control command (if ... Else ..., while ....) 4), internal function II, write-write process CreateProcedure [owner.] Store process name [; program number] [(parameter # 1, ... parameter # 1024)] [with {recompile | Encryption | Recompile, Encryption}] [ForrePlication] AS program line where the stored procedure name cannot exceed 128 words. Up to 1024 parameters during each store (SQLServer7.0 or higher), the method of use of the parameters is as follows: @ 参数 号 Data Type [Varying] [= Normal] [OUTPUT] There is a "@ @ @ @] "Symbol, each stored procedure parameter is only used inside the program, and the type of parameters is available in addition to Image, and the data types supported by other SQL Server can be used. [= Obredity] It is equivalent to setting the default value of a field when we set up a database, here is the default value for this parameter. [OUTPUT] is used to specify that the parameter is both input and output values, that is, when the stored procedure is called, if the specified parameter value is the parameters we need to enter, it also needs to be output in the results. If the item must be OUTPUT, if only the output parameter is used, you can use Cursor, and when using this parameter, you must specify the two statements of Varying and Output.

转载请注明原文地址:https://www.9cbs.com/read-121605.html

New Post(0)