Opening
Younger brother is very yearning for those technical Daniel articles, every day to see the blog feel very advanced Daniel, in order to become a technical Daniel, younger brother today also began to write a blog, hope that the elder brother help, and common progress. As the younger brother Caishuxueqian, if there is a bad place to write, forget Daniel pointed out. Thank you so much. .
Recent interview found that companies are required to be a good variety of databases, make younger brother pressure is great, I am today to summarize my study of SQL Server inside some basic content it.
I. Without input and OUTPUT parameters
1 UseNorthwind;2 GO3 4 IF exists(Select * fromDbo.sysobjectswhereId=object_id(N'[dbo]. [Sp_name]') and ObjectProperty(ID, N'isprocedure')= 1)5 BEGIN --determine if the stored procedure already exists in the database6 DROP PROCEDURESp_name;7 END8 GO9 CREATE PROCEDURESp_nameTen as One BEGIN A SELECT * fromEmployees - END - EXECSp_name;
View Code
Two. With input parameters
1 IF exists(Select * fromDbo.sysobjectswhereId=object_id(N'[dbo]. [Sp_employees_getbyid]') and ObjectProperty(ID, N'isprocedure')= 1)2 BEGIN /*determine if the stored procedure already exists in the database*/3 DROP PROCEDURESp_employees_getbyid;4 END5 GO6 CREATE PROCEDURESp_employees_getbyid7 (8 @LastName varchar( -),9 @FirstName varchar( -)Ten ) One as A BEGIN - SELECT TOP 3 * fromEmployees EWHEREE.firstname= @FirstName andE.lastname= @LastName; - END the --Execution - EXECSp_employees_getbyid'Davolio','Nancy';
View Code
SQL Server Stored Procedure basics