一个sql存储过程创建实例。
sql语句,如下:
8> CREATE TABLE Shippers (
9> ShipperID int NOT NULL ,
10> CompanyName nvarchar (40) NOT NULL ,
11> Phone nvarchar (24) NULL
12> )
13> GO
1>
2>
3> INSERT Shippers VALUES(1,'Express','(503) 555-9831')
4> INSERT Shippers VALUES(2,'Package','(503) 555-3199')
5> INSERT Shippers VALUES(3,'Shipping','(503) 555-9931')
6> go
(1 rows affected)
(1 rows affected)
(1 rows affected)
--创建sql存储过程
1> CREATE PROC spShippers
2> AS
3> SELECT * FROM Shippers
4> GO
1> EXEC spShippers
2> GO
ShipperID CompanyName Phone
----------- ---------------------------------------- ------------------------
1 Express (503) 555-9831
2 Package (503) 555-3199
3 Shipping (503) 555-9931
(3 rows affected)
--删除sql存储过程
1> drop PROC spShippers;
2> GO
1>
2> drop table Shippers;
3> GO